VBA Autofill with a dynamic range
Hi Guys,
Could anyone advice, how would I use the autofill method using a dynamic range. I'm always copying a dynamic range from sheet "Outputsheet" to sheet "Data".
The dynamic range of data is always copied to Sheet "Data" column D based on the last empty row.
Once that's done, I need to do the the following:
1. Fill in last empty row in column C with todays date formula "= Today ()"
Then dynamically autofill Today's date formula "Today ()" to all the empty rows until cells in column D-S are filled are not empty ((In other words, depending on what's entered in columns D-S))
I'm not able to set out the formula for this.
2. I also need to autofill a formula in column T & S to all empty rows until cells in column D-S are filled in ((In other words, depending on what's entered in columns D-S)
Below is my formula moving data from sheet "Outputsheet" to Sheet "Data" and my trial on the autofill formula. I would be greatly thankful for your advice on this. I've been working on this all day. Thank you
Sheets("Outputsheet").Activate
Dim sht As Worksheet
Dim LastRow As Long
Dim LastColumn As Long
Dim StartCell As Range
Set sht = Worksheets("Outputsheet")
Set StartCell = Range("A2")
'Refresh UsedRange
' Worksheets("Sheet4").UsedRange
'Find Last Row and Column
LastRow = StartCell.SpecialCells(xlCellTypeLastCell).Row
LastColumn = StartCell.SpecialCells(xlCellTypeLastCell).Column
'Select Range
sht.Range(StartCell, sht.Cells(LastRow, LastColumn)).Select
Selection.Copy
Sheets("Data").Activate
Range("D" & Rows.Count).End(xlUp).Offset(1).Select
Selection.PasteSpecial Paste:=xlPasteValues
'Update dates with today's date using autofill method
LastColumn = Cells(4, Columns.Count).End(xlToLeft).Column
LastRow = Cells(Rows.Count, "D").End(xlUp).Row
Range("C" & Rows.Count).End(xlUp).Offset(1).Select
ActiveCell.Formula = "=TODAY()"
Selection.AutoFill Destination:=Range("C2:C" & Range("D" & Rows.Count)).End(xlUp).Row
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago