Created
June 13, 2022 18:23
-
-
Save elyse0/c5a570f8405dae363246d224f275c70d to your computer and use it in GitHub Desktop.
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
Function IsDate(cellValue) As Boolean | |
If Len(cellValue) > 9 Then | |
IsDate = True | |
Else | |
IsDate = False | |
End If | |
End Function | |
Sub SetDates() | |
Dim SelectedRange As Range | |
Set SelectedRange = Selection | |
RowCount = SelectedRange.Rows.Count | |
FirstRowIndex = CInt(Split(SelectedRange.Cells(1).Address, "$")(2)) | |
LastRowIndex = FirstRowIndex + (RowCount - 1) | |
Dim GroupDate As String | |
For i = FirstRowIndex To LastRowIndex Step 1 | |
Dim CellValueColumnA As String | |
Dim CellValueColumnB As String | |
CellValueColumnA = Cells(i, "A").Text | |
CellValueColumnB = Cells(i, "B").Text | |
If IsDate(CellValueColumnA) And CellValueColumnA = CellValueColumnB Then | |
GroupDate = Cells(i, "A").Text | |
MsgBox GroupDate | |
Else | |
MsgBox GroupDate | |
Cells(i, "A").NumberFormat = "@" | |
Cells(i, "A").Value = GroupDate | |
End If | |
Next i | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment