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
Dim variable as SomeObjectType | |
Set variable = New SomeObjectType |
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
Dim variable as Object | |
Set variable = CreateObject("SomeObjectType") |
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 TestCreateGUID() | |
'Dim t As Scriptlet.TypeLib <~ error, user type not defined | |
'Dim t As Scriptlet.IGenScriptletTLib <~ at least compiles | |
'Debug.Print t.Name <~ error, object or with block variable not set | |
' i.e. doesn't understand t as a variable | |
'Debug.Print t.GUID <~ same | |
'Debug.Print t.AnyOtherListedMethodOnThisObject | |
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 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 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 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 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 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 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 |