Greetings all, trying to write a macro that will format a column based on the header in row 1. In the attached example, the header will include “geo_start_date”, “geo_end_date” and sometimes “wide_release.” These columns need to be formatted as dates (see difference between Start and End worksheets in my example). However, these columns could shift in different reports. For example, “geo_start_date” could be in column E or col F. Basically trying to write an IF statement – something like this:
IF (cell in row 1) = “geo_start_date” THEN format the entire column as a date (month/day/year format).
Help is much appreciated, thanks!
try this code
Public Sub formating()
Dim i As Integer, j As Long
For i = 1 To 20
If ActiveSheet.Cells(1, i).Value = "geo_start_date" Then
For j = 2 To 1000
ActiveSheet.Cells(j, i).Value = Format(ActiveSheet.Cells(j, i).Value, "Short Date")
Next j
End If
Next i
End Sub
That works - thanks so much!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks