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
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 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 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 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 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 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 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 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 DeleteRowsFastWithAutofilter() | |
Dim wksData As Worksheet | |
Dim rngDataBlock As Range | |
Dim lngLastRow As Long, lngLastCol As Long | |
'Set references up-front | |
Set wksData = ThisWorkbook.Sheets("data") | |
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 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 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 TransposeHorizontalToVertical() | |
Dim lngLastRow As Long, lngIdx As Long, lngOutputLastRow As Long, _ | |
lngDetailsIdx As Long, lngTargetRow As Long, lngTargetCol As Long | |
Dim wksInput As Worksheet, wksOutput As Worksheet | |
Dim varDetailNames As Variant, varMonthNames As Variant, _ | |
varDetails As Variant, varValues As Variant | |
Dim varDetailsKey As Variant, varValuesKey As Variant | |
Dim dicDetails As Scripting.Dictionary, dicValues As Scripting.Dictionary |
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 | |
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 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 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 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 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 | |