WindsorKnot
Board Regular
- Joined
- Jan 4, 2009
- Messages
- 160
Hi,
I'm trying to make my code run faster by using a dynamic Array.
However, I keep on getting an error everytime I run my code. The error is Object variableor with block variable not set.
Where the error occurs is highlighted in red.
Can someone help me out with this particular issue?
Thanks.
I'm trying to make my code run faster by using a dynamic Array.
However, I keep on getting an error everytime I run my code. The error is Object variableor with block variable not set.
Where the error occurs is highlighted in red.
Can someone help me out with this particular issue?
Thanks.
Code:
Sub rangevalue()
Application.ScreenUpdating = False
Dim lsheets() As Worksheet, i As Integer, NSheets as Integer
Nsheets = ActiveWorkbook.Worksheets.Count
ReDim lsheets(1 To Nsheets) ' Declares the array variable size
For i = 1 To Nsheets
[COLOR=red][B]lsheets(i).Activate[/B][/COLOR]
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Next i
Application.CutCopyMode = False
End Sub