Hi. I'm trying to edit this macro
This works but when I add that I want to copy another cell Q it stops working. This is the VBA that I want to fix:
Thanks for any help!
Code:
Sub copy_last_row100()
Dim ws1 As Worksheet: Set ws1 = Sheets("P_L events up to 2 months")
Dim ws2 As Worksheet: Set ws2 = Sheets("Sheet1")
Dim LR As Long
Dim WkRg As Range
With ws1
'lastrow of sheet
LR = ws1.Range("A4:A" & ws1.Range("A" & Rows.Count).End(xlUp).Row).Find("*", , xlValues, xlWhole, , xlPrevious).Row
Set WkRg = Union(.Cells(LR, "B"), .Cells(LR, "C"), .Cells(LR, "G"), .Cells(LR, "P"))
End With
'Copy lastrow columns B,C,G,P to sheet1
WkRg.Copy
ws2.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub
This works but when I add that I want to copy another cell Q it stops working. This is the VBA that I want to fix:
Code:
Sub copy_last_row100()
Dim ws1 As Worksheet: Set ws1 = Sheets("P_L events up to 2 months")
Dim ws2 As Worksheet: Set ws2 = Sheets("Sheet1")
Dim LR As Long
Dim WkRg As Range
With ws1
'lastrow of sheet
LR = ws1.Range("A4:A" & ws1.Range("A" & Rows.Count).End(xlUp).Row).Find("*", , xlValues, xlWhole, , xlPrevious).Row
Set WkRg = Union(.Cells(LR, "B"), .Cells(LR, "C"), .Cells(LR, "G"), .Cells(LR, "P")), .Cells(LR, "Q")
End With
'Copy lastrow columns B,C,G,P,Q to sheet1
WkRg.Copy
ws2.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub
Thanks for any help!