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
Option Explicit | |
Public Sub ZipFoldersInColumn() | |
Dim wks As Worksheet | |
Dim lngIdx As Long, lngErrorCode | |
Dim strFullPath As String, strZipName As String, strEndFound As String, _ | |
strCommand As String, strTargetDir As String | |
Dim blnEndFound As Boolean | |
Dim wsh As WshShell | |
Set wsh = New WshShell |
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 CollectUniques(rng As Range) As Collection | |
Dim varArray As Variant, var As Variant | |
Dim col As Collection | |
'Guard clause - if Range is nothing, return a Nothing collection | |
'Guard clause - if Range is empty, return a Nothing collection | |
If rng Is Nothing Or WorksheetFunction.CountA(rng) = 0 Then | |
Set CollectUniques = col | |
Exit Function |
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
Option Explicit | |
Public Sub CombineDataFromAllSheets() | |
Dim wksSrc As Worksheet, wksDst As Worksheet | |
Dim rngSrc As Range, rngDst As Range | |
Dim lngLastCol As Long, lngSrcLastRow As Long, lngDstLastRow As Long | |
'Notes: "Src" is short for "Source", "Dst" is short for "Destination" | |
'Set references up-front |
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
Option Explicit | |
'This subroutine prompts the user to select dates | |
Public Sub PromptUserForInputDates() | |
Dim strStart As String, strEnd As String, strPromptMessage As String | |
'Prompt the user to input the start date | |
strStart = InputBox("Please enter the start date") | |
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
Option Explicit | |
Public Sub CombineManyWorkbooksIntoOneWorksheet() | |
Dim strDirContainingFiles As String, strFile As String, _ | |
strFilePath As String | |
Dim wbkDst As Workbook, wbkSrc As Workbook | |
Dim wksDst As Worksheet, wksSrc As Worksheet | |
Dim lngIdx As Long, lngSrcLastRow As Long, _ | |
lngSrcLastCol As Long, lngDstLastRow As Long, _ | |
lngDstLastCol As Long, lngDstFirstFileRow 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
Option Explicit | |
Public Function CreateGUID(Optional IncludeHyphens As Boolean = True, _ | |
Optional IncludeBraces As Boolean = False) _ | |
As String | |
Dim obj As Object | |
Dim strGUID As String | |
'Late-bind obj as a TypeLib -- a rare time when late-binding | |
'is actually a must! |
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
Option Explicit | |
Public Sub CalculateResultsAndAddAsColumn() | |
Dim rngCategory As Range, rngResults As Range | |
Dim varCategory As Variant, varResults As Variant | |
Dim lngIdx As Long, lngLastRow As Long | |
Dim wksData As Worksheet | |
Dim strFirstLetter As String | |
'First things first: let's set up our basic variables |
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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
'INPUT : Sheet, the worksheet we'll search to find the last column | |
' : RowNum, the row (as a number) we're interested in | |
'OUTPUT : Long, the last occupied column in the specified row | |
'SPECIAL CASE : if a bad row number is entered (anything < 1), return 0 | |
'EXAMPLES BELOW: | |
' | |
'assume that on MySheet, cells A1:F1 are occupied, | |
'but B3 is the only occupied cell in row 3 | |
'LastColNumInRow(MySheet, 3) |
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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
'INPUT : Sheet, the worksheet we'll search to find the last column | |
'OUTPUT : Long, the last occupied column | |
'SPECIAL CASE : if Sheet is empty, return 1 | |
'EXAMPLES BELOW: | |
' | |
'assume that there is a single entry on MySheet in cell C3 | |
'LastColNum(MySheet) | |
'>> 3 | |
' |
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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
'INPUT : True or False (i.e. fast or slow) | |
'DESCRIPTION : this sub turns off screen updating and alarms then | |
' sets calculations to manual | |
' | |
Public Sub GoFast(OnOrOff As Boolean) | |
Dim CalcMode As XlCalculation | |
CalcMode = Application.Calculation | |
With Application | |
.ScreenUpdating = Not OnOrOff |