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 WriteFakeLastNames() | |
Dim wksNames As Worksheet | |
Dim lngLastRow As Long, lngIdx As Long | |
Dim strOldName As String, strNewName As String | |
'Set references up-front | |
Set wksNames = ThisWorkbook.Worksheets("names") | |
lngLastRow = 1001 |
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 | |
'This subroutine prompts the user to select dates | |
' | |
'Code already written and described here: | |
'http://danwagner.co/how-to-copy-data-to-a-new-workbook-based-on-dates/ | |
Public Sub PromptUserForInputDates() | |
Dim strStart As String, strEnd As String, strPromptMessage As String | |
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 | |
'This subroutine prompts the user to select dates | |
' | |
'Code already written and described here: | |
'http://danwagner.co/how-to-copy-data-to-a-new-workbook-based-on-dates/ | |
Public Sub PromptUserForInputDates() | |
Dim strStart As String, strEnd As String, strPromptMessage As String | |
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
'This subroutine creates adds the filtered data from Sheet1 | |
'to a previously-existing destination Worksheet (called "Destination" here) | |
Public Sub AddToDestinationWorksheet(StartDate As String, EndDate As String) | |
Dim wksData As Worksheet, wksTarget As Worksheet | |
Dim lngLastRow As Long, lngLastCol As Long, lngDateCol As Long, _ | |
lngDestinationLastRow As Long, lngDestinationFirstCol As Long | |
Dim rngFull As Range, rngResult As Range, rngTarget As Range | |
Dim varFiltered 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
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | |
'INPUT : Sheet, the Worksheet to turn off (clear) filters on | |
'DESCRIPTION : This sub clears (turns off) all filters on a Worksheet | |
'SPECIAL CASE: none | |
Public Sub ClearAllFilters(Sheet As Worksheet) | |
Sheet.AutoFilterMode = False | |
If Sheet.FilterMode = True Then | |
Sheet.ShowAllData | |
End If | |
End Sub |
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
'This subroutine creates adds the filtered data from Sheet1 | |
'to a previously-existing destination Worksheet (called "Destination" here) | |
Public Sub AddToDestinationWorksheet(StartDate As String, EndDate As String) | |
'... | |
'Lots of code taken out here for brevity, the first place we're going to replace | |
'the old clear filters logic starts on line 38 of the original | |
'... | |
'Replaced the commented-out code with our new Subroutine, you should actually |
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 | |
Private Sub Worksheet_SelectionChange(ByVal Target As Range) | |
'Set the context appropriately using With...End With | |
With Sheets("calendar") | |
'Clear all previously-applied highlighting for easy readability | |
.Cells.Interior.ColorIndex = xlColorIndexNone | |
'Switch on the address of the selected cell |
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 |
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 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 | |
''''''''''''''' |