G
Guest
I am using an On Error GoTo statement within a loop, however, the On Error GoTo statement only works once when crossed in the loop. Is there a way around this?
My code is:
Do Until acounter = ActiveWorkbook.Sheets.Count
sales = -Range("B14").Value
gp = -Range("B23").Value
cp = -Range("B47").Value
store = Left(Right(ActiveSheet.Name, 6), 5)
Windows(zfile).Activate
Sheets("Post Project Financials").Select
On Error GoTo sheet2
Cells.Find(What:=store, After:=ActiveCell, LookIn:=xlValues,LookAt:=
xlWhole,SearchOrder:=xlByRows,SearchDirection:=xlNext,MatchCase:=False)
.Activate
storerange = ActiveCell.Address
sheetresume:
Range(storerange).Select
Selection.Offset(0, 7).Activate
ActiveCell.Value = sales
acounter = acounter + 1
Windows(afile).Activate
ActiveSheet.Next.Select
Loop
Exit Sub
sheet2:
Sheets("Post Project Financials (2)").Select
Cells.Find(What:=store, After:=ActiveCell, LookIn:=xlValues,LookAt:=
xlWhole,SearchOrder:=xlByRows,SearchDirection:=xlNext,MatchCase:=False)
.Activate
storerange = ActiveCell.Address
GoTo sheetresume
My code is:
Do Until acounter = ActiveWorkbook.Sheets.Count
sales = -Range("B14").Value
gp = -Range("B23").Value
cp = -Range("B47").Value
store = Left(Right(ActiveSheet.Name, 6), 5)
Windows(zfile).Activate
Sheets("Post Project Financials").Select
On Error GoTo sheet2
Cells.Find(What:=store, After:=ActiveCell, LookIn:=xlValues,LookAt:=
xlWhole,SearchOrder:=xlByRows,SearchDirection:=xlNext,MatchCase:=False)
.Activate
storerange = ActiveCell.Address
sheetresume:
Range(storerange).Select
Selection.Offset(0, 7).Activate
ActiveCell.Value = sales
acounter = acounter + 1
Windows(afile).Activate
ActiveSheet.Next.Select
Loop
Exit Sub
sheet2:
Sheets("Post Project Financials (2)").Select
Cells.Find(What:=store, After:=ActiveCell, LookIn:=xlValues,LookAt:=
xlWhole,SearchOrder:=xlByRows,SearchDirection:=xlNext,MatchCase:=False)
.Activate
storerange = ActiveCell.Address
GoTo sheetresume