Trying_hard
Trying_hard

Reputation: 9501

Formatting Todays date to match a Column length

I am trying to have a macro that will do some formatting. I need to fill in todays date in Column A all the way down, but only to match the length of column B. Below I have an example.

 Date       
         1          2
         1          2
         1          2

The column A under date I would need the macro to know to stop at A3 because column B stops at B3, but if the next day I run this column B stops at B20 I would need the macro to fill in date to A20.

I am stuck on getting a length formatting formula to work. Any help would be great.

Upvotes: 0

Views: 81

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149295

Like this?

Sub Sample()
    Dim LRow As Long

    With Sheets("Sheet1")
        LRow = .Range("B" & .Rows.Count).End(xlUp).Row

        .Range("A1:A" & LRow).Value = Date
        .Columns(1).EntireColumn.AutoFit
    End With
End Sub

Upvotes: 2

Related Questions