This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub ArraySlice() | |
Dim myArray() As Variant | |
With ThisWorkbook.Sheets(1) | |
myArray = .Range(.Cells(1, 1), .Cells(12, 6)).Value | |
End With | |
Dim temp(1 To 12) As Variant | |
Dim i As Long |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub KeepDuplicates() | |
'Create one array for our raw data and one array for our duplicates | |
Dim varDataArr() As Variant, varDupesArr() As Variant | |
'Create some counters for our loops | |
Dim i As Long, j As Long, k As Long, count As Long | |
'Create a Boolean variable to tell us if we find a matching value | |
Dim bolMatch As Boolean | |
'Load the selection into our raw data array, varDataArr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function MostRecentFile(ByVal FileName As String, ByVal FolderName As String) As String | |
Dim objFileSys As FileSystemObject | |
Dim objFile As File | |
Dim objFolder As Object | |
Dim strFilename As String | |
Dim datFile As Date | |
Dim strDir As String | |
'Set file path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub PdfToExcelSendKey() | |
Dim task | |
' open the file | |
' change the path of adobe program as per your desktop | |
task = Shell("C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe " & "C:\Documents and Settings\e531210\Desktop\test.pdf", vbNormalFocus) | |
' wait 2 secs | |
Application.Wait Now + TimeValue("00:00:2") | |
'send key to select all text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub ImportExcelWorksheetData() | |
Dim strPath As String | |
strPath = "C:\Documents and Settings\Some Folder\temp.xls" | |
DoCmd.TransferSpreadsheet acImport, , "tblTemp", _ | |
strPath, True | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub MakeTempWorkbook(ByVal FileName As String) | |
'Edit this if you need to change the path where the temp file is saved | |
Dim strTempLocation As String | |
strTempLocation = "C:\Documents and Settings\temp.xls" | |
'Declare our variables | |
Dim xlApp As Excel.Application | |
Set xlApp = CreateObject("Excel.Application") | |
Dim xlWb As Excel.Workbook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub Copy_Folder(ByVal FromPath As String, ByVal ToPath As String, ByRef LogSheet As Worksheet, ByVal i As Integer) | |
'Note: If ToPath already exists it will overwrite existing files in this folder | |
'if ToPath does not exist it will be made for you. | |
Dim FSO As Object | |
'Trim the paths just in case the user adds the \ at the end of the path | |
If Right(FromPath, 1) = "\" Then | |
FromPath = Left(FromPath, Len(FromPath) - 1) | |
End If |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function LastRow__lng(ByRef wksWorksheet As Worksheet) As Long | |
''Stores the last row with data on it | |
Dim lngLowestRow As Long | |
''Temp to hold the last row of each column | |
Dim lngTempRow1 As Long | |
Dim lngTempRow2 As Long | |
''Greater value of Dim lngTempRow1 & lngTempRow2 | |
Dim lngColRange As Long | |
''Used as counter in loop | |
Dim objColumn As Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub OffAutos(ByVal bolState As Boolean) | |
If bolState = True Then | |
With Application | |
.Calculation = xlCalculationManual | |
.ScreenUpdating = False | |
.DisplayAlerts = False | |
.AskToUpdateLinks = False | |
End With | |
Else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub ToggleManualCalcs() | |
If Application.Calculation = xlCalculationAutomatic Then | |
Application.Calculation = xlCalculationManual | |
Else | |
Application.Calculation = xlCalculationAutomatic | |
End If | |
End Sub |