Jed Shields
Active Member
- Joined
- Sep 7, 2011
- Messages
- 283
- Office Version
- 365
- Platform
- Windows
Morning al,
I need a bit of help with this, it's falling over on the last line. Basically, I'm copying all the data from All Data Current sheet to the bottom of All Data History Sheet This works fine. The History sheet has one more column where I tag the date (1/8/18, 1/9/18 etc.). The code manages to copy and paste the date from Macro E18 to the botom of the date column where there's the date for the last months data, but the final line that nees to copy it down to the bottom of the list doesn't work. Any ideas? Apologies, the code isn't pretty and could probably be done more efficiently...
Dim LRowC As Variant
Dim LRowH As Variant
Dim LRowH2 As Variant
Dim DCell As Variant
Sheets("All Data History").Select
With ActiveSheet
LRowH = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Sheets("All Data Current").Select
With ActiveSheet
LRowC = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
ActiveSheet.Range("$A$2:$X" & LRowC).SpecialCells _
(xlCellTypeVisible).Copy
Sheets("All Data History").Range("A" & LRowH + 1).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False 'Doesn't add data to clipboard
Sheets("All Data History").Select
With ActiveSheet
LRowH2 = .Cells(.Rows.Count, "A").End(xlUp).Row
' DCell = .Range(.Rows.Count, "Y" & LRowH + 1).Cell
End With
Range("Y" & LRowH + 1).Select
ActiveCell.Formula = "=Macros!$E$16"
Range("Y" & LRowH + 2).AutoFill Destination:=Range(DCell & ":y" & LRowH2)
End Sub[/CODE]
I need a bit of help with this, it's falling over on the last line. Basically, I'm copying all the data from All Data Current sheet to the bottom of All Data History Sheet This works fine. The History sheet has one more column where I tag the date (1/8/18, 1/9/18 etc.). The code manages to copy and paste the date from Macro E18 to the botom of the date column where there's the date for the last months data, but the final line that nees to copy it down to the bottom of the list doesn't work. Any ideas? Apologies, the code isn't pretty and could probably be done more efficiently...
Dim LRowC As Variant
Dim LRowH As Variant
Dim LRowH2 As Variant
Dim DCell As Variant
Sheets("All Data History").Select
With ActiveSheet
LRowH = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Sheets("All Data Current").Select
With ActiveSheet
LRowC = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
ActiveSheet.Range("$A$2:$X" & LRowC).SpecialCells _
(xlCellTypeVisible).Copy
Sheets("All Data History").Range("A" & LRowH + 1).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False 'Doesn't add data to clipboard
Sheets("All Data History").Select
With ActiveSheet
LRowH2 = .Cells(.Rows.Count, "A").End(xlUp).Row
' DCell = .Range(.Rows.Count, "Y" & LRowH + 1).Cell
End With
Range("Y" & LRowH + 1).Select
ActiveCell.Formula = "=Macros!$E$16"
Range("Y" & LRowH + 2).AutoFill Destination:=Range(DCell & ":y" & LRowH2)
End Sub[/CODE]