Created
February 8, 2023 17:04
-
-
Save RobertAKARobin/5e5724c52f7138ed99005f949ac1082e to your computer and use it in GitHub Desktop.
Evan's stuff
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
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