Hi All, in need of some help. i have the below code which works perfectly by stacking data from each tab stated and copying to another workbook. however when it reaches a tab with no data i get an error message. but the data still copies fine. is there a way to avoid this error coming up after the macro has ran as it doesnt effect the data import.
the highlight part of my code is where it fails. thank you
the highlight part of my code is where it fails. thank you
VBA Code:
Sub StackData ()
Application.ScreenUpdating = False
Sheets("Commentary").Select
Dim wkbSource As Workbook, wsDest As Worksheet, ws As Worksheet, lRow As Long
Set wsDest = ThisWorkbook.Sheets("Commentary")
Set wkbSource = Workbooks.Open("z:\location\XXXXX.xlsx")
For Each ws In Sheets(Array("8.30 - 10.00", "10.00 - 12.00", "12.00 - 14.00", "14.00 - 16.00", "16.00 - 17.30"))
With ws
>>>>>>***********lRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Cells(2, 1).Resize(lRow - 1, 7).Copy wsDest.Cells(wsDest.Rows.Count, "I").End(xlUp).Offset(1)********* <<<<<<<
End With
Next ws
wkbSource.Close False
Application.ScreenUpdating = True
End Sub