Guys, I'm trying to select all the cells on my worksheet. In order to do so, I was thinking about trying to use range and the variables lr and lc which stand for last row and last column. However, currently it's not working.
This is the code I have:
Any hint?
Thanks!
This is the code I have:
Code:
Sub Graphs()
Dim lr As Integer, lc As Integer, r As Integer
Application.ScreenUpdating = False
lr = data.Cells(Rows.Count, 1).End(xlUp).Row
lc = data.Cells(1, Columns.Count).End(xlToRight).Column
lc2 = Columns(lc)
For r = 1 To lr
data.Rows(r).Copy
data_pivot.Select
data_pivot.Cells(r, 1).Select
data_pivot.Paste
Next
Application.ScreenUpdating = True
MsgBox "Copy done"
data_pivot.Range(Cells(1, 1), Cells(lr, lc)).Select
Range("A1:H540").Select
End Sub
Any hint?
Thanks!
Last edited: