Skip to content

Instantly share code, notes, and snippets.

@richard512
Created October 27, 2017 01:49
Show Gist options
  • Save richard512/1ef6430dfdb1e3062d629f60b3963c97 to your computer and use it in GitHub Desktop.
Save richard512/1ef6430dfdb1e3062d629f60b3963c97 to your computer and use it in GitHub Desktop.
Finds last column value in the first row and makes a date column from it
Sub MakeDateColumn()
If Range("A1").Value = "Date" Then
MsgBox "Already have Date column"
Exit Sub
End If
With Range("A1:Z1")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
strDate = c.Value
End If
End With
Range("A1").EntireColumn.Insert
Range("A1").Value = "Date"
LastRow = Range("B" & Rows.Count).End(xlUp).Row
Range("A2:A" & LastRow) = strDate
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment