Hi everyone
I've been working on a project and have come across a run time error and I'm not sure what's wrong.
Here's the code I have
The run-time error occurs on the following line
Any idea/help is much appreciated
Thanks
I've been working on a project and have come across a run time error and I'm not sure what's wrong.
Here's the code I have
Code:
Sub GenerateSummaryYee()
Dim lr As Long
Dim adr As String
Dim jobt As Long
Dim bal As Long
'Define Yee array
Yee = Array("1235 Law 11-8a", "2526 Roof", "2922 Roof", "1110 Roof", "2145-2147 Roof", "20 East", "1235 Roof", "2125", "2526 Local Law 11", _
"2070 Roof", "1221-1227", "3556 Roof", "2805 G.C Roof", "2499 Roof", "1235 Windows", "1900 Roof", "960 Windows", "2185 G.C Roof", "2720 Roof", _
"1895 Roof", "20 East Roof", "2141-2143 Roof", "2685", "2499 Roof", "2499 Brick work", "940 Windows", "2185 Bolton Roof", "3525 Roof", _
"1000 G.C - Brick work, Lintels & Sills")
'Loop through worksheets of Yee array
For i = LBound(Yee) To UBound(Yee)
With Worksheets(Yee(i))
'find last row of data
lr = .Cells(Rows.Count, 1).End(xlUp).Row
'add values to variables
adr = .Cells(lr, 1).Value
jobt = .Cells(lr, 2).Value
bal = .Cells(lr, 5).Value
End With
'dump data into summary sheet
With Worksheets("SUMMARY")
'start at row 7
If x = "" Then x = 7
'If the value of bal is 0 then do nothing and go to next
If bal <> 0 Then
'Otherwise, assign values to cells
.Cells(x, 1).Value = adr
.Cells(x, 2).Value = jobt
.Cells(x, 3).Value = bal
x = x + 1
End If
End With
Next i
End Sub
The run-time error occurs on the following line
Code:
With Worksheets(Yee(i))
Any idea/help is much appreciated
Thanks