Skip to content

Instantly share code, notes, and snippets.

@RobertAKARobin
Created February 8, 2023 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobertAKARobin/5e5724c52f7138ed99005f949ac1082e to your computer and use it in GitHub Desktop.
Save RobertAKARobin/5e5724c52f7138ed99005f949ac1082e to your computer and use it in GitHub Desktop.
Evan's stuff
Function GetFirstEmptyCell(Direction As String, StartRowIndex As Integer, StartColIndex As Integer) As Range
Dim CurrentRowIndex As Integer, CurrentColIndex As Integer, CurrentCell As Range
CurrentRowIndex = StartRowIndex
CurrentColIndex = StartColIndex
Do While True
Set CurrentCell = Cells(CurrentRowIndex, CurrentColIndex)
If IsEmpty(CurrentCell.Value) Then
Set GetFirstEmptyCell = CurrentCell
Exit Function
End If
Select Case Direction
Case "Right"
CurrentColIndex = CurrentColIndex + 1
Case "Down"
CurrentRowIndex = CurrentRowIndex + 1
Case Else
MsgBox "Invalid direction"
End
End Select
Loop
End Function
Sub DeleteUneededWeeks()
Dim FirstEntryRowIndex As Integer
Dim FirstWeekColIndex As Integer
Dim CurrentWeekCol As Range
Dim CurrentWeekColIndex As Integer
FirstEntryRowIndex = 3
FirstWeekColIndex = 5
CurrentWeekColIndex = GetFirstEmptyCell("Right", FirstEntryRowIndex, FirstWeekColIndex).Column - 1
Set CurrentWeekCol = Columns(CurrentWeekColIndex)
Columns(FirstWeekColIndex).Resize(, CurrentWeekColIndex - FirstWeekColIndex).Delete
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment