mikenelena
Board Regular
- Joined
- Mar 5, 2018
- Messages
- 139
- Office Version
- 365
- Platform
- Windows
So I'm looking to copy a range from a newly created, temporary query sheet to a permanent sheet with the code below. Hitting Control + End on the Query2 sheet brings me to I109, exactly what I would expect. Hovering over the LR variable in the code shows 109. Debug.printing the variable shows 109. Yet, for reasons I can't understand, when I try to copy the range, the program is selecting all the way down to row 2109. Can anyone offer any ideas as to what I'm doing wrong?
Thanks!
...Mike
Thanks!
...Mike
Code:
Sub Copy_PasteDataToMainTab() 'This copies the current payroll data from the filtered query into the "Main" payroll tab.
Dim LR As Long
Dim ws2 As Worksheet
Dim ws As Worksheet
Set ws2 = Worksheets("Query2")
Set ws = Worksheets("Main")
ws.Activate
LR = ws2.Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
ws2.Activate
Range("A2:G2" & LR).Copy
ws.Range("A" & Rows.Count).End(3)(2).PasteSpecial Paste:=xlPasteValuesAndNumberFormats '----> Copies values and number formats only to Main starting in Column A
ws.Activate
Application.ScreenUpdating = True
Application.CutCopyMode = False
Range("D1").Select
Call RowColor
End Sub