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 SplitCampersByCabin() | |
Dim lngLastRow As Long, lngIdx As Long, lngNextCol As Long, _ | |
lngCabinRow As Long | |
Dim wksCampers As Worksheet, wksCabins As Worksheet | |
Dim varCamper As Variant, varCabin As Variant | |
Dim dicCampers As Scripting.Dictionary, _ | |
dicCabins As Scripting.Dictionary | |
Dim strCamper As String, strCabin As String |
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 DeleteBlankRows() | |
Dim wks As Worksheet | |
Dim lngLastRow As Long, lngLastCol As Long, lngIdx As Long, _ | |
lngColCounter As Long | |
Dim blnAllBlank As Boolean | |
'First things first: we identify our basic variables | |
Set wks = ThisWorkbook.Worksheets("hello") |
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
def spinner | |
colors = ["Red", "Blue", "Yellow", "Green"] | |
appendages = ["Left Hand", "Right Hand", "Left Foot", "Right Foot"] | |
puts "Place your #{appendages.sample} on #{colors.sample}!" | |
end | |
spinner |
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 DeleteRowsSlowly() | |
Dim lngIdx As Long | |
For lngIdx = 100000 To 1 Step -1 | |
If Cells(lngIdx, 1).Value = vbNullString Then | |
Cells(lngIdx, 1).EntireRow.Delete | |
End If | |
Next lngIdx | |
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
Option Explicit | |
Public Sub DeleteRowsLessThanFiftySlowly() | |
Dim lngIdx As Long | |
For lngIdx = 100000 To 1 Step -1 | |
If Cells(lngIdx, 1).Value < 50 Then | |
Cells(lngIdx, 1).EntireRow.Delete | |
End If | |
Next lngIdx | |
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
Option Explicit | |
Public Sub DeleteDatesMoreRecentThanFebFirstSlowly() | |
Dim lngIdx As Long | |
For lngIdx = 1000000 To 1 Step -1 | |
If Cells(lngIdx, 1).Value > DateValue("2/1/2013") Then | |
Cells(lngIdx, 1).EntireRow.Delete | |
End If | |
Next lngIdx | |
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
Option Explicit | |
Public Sub ExtractInfoFromSquareBrackets() | |
Dim wksRaw As Worksheet | |
Dim strPattern As String, strRaw As String, strMatch As String | |
Dim rngAllRows As Range, rngCell As Range | |
Dim lngLastRow As Long, lngIdx As Long | |
Dim objMatches As Object | |
Dim rgx As RegExp | |
Set rgx = New RegExp |
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 SaveSheetsAsPDF() | |
Dim wksAllSheets As Variant | |
Dim wksSheet1 As Worksheet | |
Dim strFilename As String, strFilepath As String | |
'Set references up-front | |
Set wksSheet1 = ThisWorkbook.Sheets("Sheet1") | |
wksAllSheets = Array("Sheet1", "Sheet2", "Sheet3") |
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 MoveDataBasedOnDropDown() | |
Dim strInput As String, strPromptMessage As String | |
Dim wksAllocate As Worksheet, wksTarget As Worksheet | |
Dim obj As Object | |
Dim lngAllocateLastRow As Long, lngAllocateLastCol As Long, _ | |
lngTargetLastRow As Long | |
Dim rngAllocate As Range, rngTarget 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
Option Explicit | |
Public Sub RunBatchFile() | |
Dim strCommand As String | |
Dim lngErrorCode As Long | |
Dim wsh As WshShell | |
Set wsh = New WshShell | |
'Run the batch file using the WshShell object | |
strCommand = Chr(34) & _ |