This file contains hidden or 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 hidden or 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 CombineSheetsWithDifferentHeaders() | |
Dim wksDst As Worksheet, wksSrc As Worksheet | |
Dim lngIdx As Long, lngLastSrcColNum As Long, _ | |
lngFinalHeadersCounter As Long, lngFinalHeadersSize As Long, _ | |
lngLastSrcRowNum As Long, lngLastDstRowNum As Long | |
Dim strColHeader As String | |
Dim varColHeader As Variant | |
Dim rngDst As Range, rngSrc As Range |
This file contains hidden or 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 TestContains() | |
'Test "primitives" collection (i.e. Strings, Longs, etc.) | |
Dim colStrings As Collection | |
Set colStrings = New Collection | |
'Add Item / Key pairs (of strings) | |
colStrings.Add Item:="Item1", Key:="Key1" | |
colStrings.Add Item:="Item2", Key:="Key2" |
This file contains hidden or 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 : Kollection, the collection we would like to examine | |
' : (Optional) Key, the Key we want to find in the collection | |
' : (Optional) Item, the Item we want to find in the collection | |
'OUTPUT : True if Key or Item is found, False if not | |
'SPECIAL CASE: If both Key and Item are missing, return False | |
Option Explicit | |
Public Function Contains(Kollection As Collection, Optional Key As Variant, Optional Item As Variant) As Boolean | |
Dim strKey As String | |
Dim var As Variant |
This file contains hidden or 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 FastMarkDuplicatesWithDictionary() | |
'For timing purposes only -- this does not affect our macro! | |
Dim dblStart As Double | |
dblStart = Timer | |
Dim wksIDs As Worksheet | |
Dim varIDs As Variant, varStatus As Variant, _ | |
varID As Variant |
This file contains hidden or 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 InsertNewRowsBasedOnValues() | |
Dim wksData As Worksheet | |
Dim lngLastRow As Long, lngIdx As Long, _ | |
lngStudentCol As Long, lngItemCol As Long, lngNetAmtCol As Long, _ | |
lngPreviousAmtCol As Long, lngNewAmtCol As Long, _ | |
lngReversalCol As Long | |
Dim varRowNum As Variant | |
Dim colRowNumsForInsert As Collection |
This file contains hidden or 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 CombineCertainSheets() | |
Dim wks As Worksheet, wksDst As Worksheet | |
Dim strName As String | |
Dim lngSrcLastRow As Long, lngDstLastRow As Long, _ | |
lngLastCol As Long | |
Dim rngSrc As Range, rngDst As Range, rngToClear As Range | |
'Set references up-front |
This file contains hidden or 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 MEDIANIFS(median_range As Range, ParamArray range_and_criteria_pairs()) | |
Dim lngIdx As Long, lngMedianRowIdx As Long, lngCriteriaIdx As Long | |
Dim strOperator As String | |
Dim varThreshold As Variant, varAccumulator() As Variant | |
ReDim varAccumulator(0) | |
Dim blnAllMatched As Boolean | |
''''''''''''''' |
This file contains hidden or 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 ConvertSemicolonTextToXLS() | |
Dim fdoUserPicks As FileDialog | |
Dim strMessage As String, strFilename As String | |
Dim wbkData As Workbook | |
Dim lngIdx As Long | |
'Leverage the already-written-for-you PromptUserToSelectFiles | |
'function from the VBA Toolbelt to prompt the user to select files |
This file contains hidden or 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 |