Auto fill based on data in other columns

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In excel, I have 3 columns that always have the same number of rows with data
in them. I want the other two columns to automatically prefill, one with
todays date and the other with the text of GESV. I've tried doing this with
a macro, but since the row count will be different each day, is there some
VBA code I can use that will fill columns 4 & 5 the same number of rows as
col 1, 2 AND 3. Thanks so much for your help.
 
Sub g()
Dim ws As Worksheet
Dim RowNum%, rs%

Set ws = Worksheets("Sheet1")
RowNum = ws.Range("A1").End(xlDown).Row

For rs = 1 To RowNum
ws.Range("D" & rs) = Date
ws.Range("E" & rs) = "GESV"
Next rs

'If you want to ensure that subsequent rows from previous sessions arent
filled, also enter :
RowNum = RowNum + 1

If ws.Range("D" & RowNum) <> "" Then
ws.Range("D" & RowNum & ":E" & ws.Range("D" &
RowNum).End(xlDown).Row).ClearContents
End If
End Sub
 
Back
Top