Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default On Error GoTo

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:=xlN ext,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:=xlN ext,MatchCase:=False)
.Activate
storerange = ActiveCell.Address
GoTo sheetresume

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default On Error GoTo

Stan,

To clear the error handling state, you need to use Resume rather
than Goto in your error handling code. Change

GoTo sheetresume

to

Resume sheetresume


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"StanJ" wrote in message
...
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:=xlN ext,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:=xlN ext,MatchCase:=
False)
.Activate
storerange = ActiveCell.Address
GoTo sheetresume



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Meaning of On Error Goto 0 FARAZ QURESHI Excel Discussion (Misc queries) 5 May 4th 09 12:43 PM
On error goto problem Coppercrutch Excel Discussion (Misc queries) 3 December 28th 07 03:04 PM
How can I still go to the error-code after a On Error Goto? Michel[_3_] Excel Programming 2 May 4th 04 04:21 AM
On error goto 0? Brian Tozer Excel Programming 10 December 29th 03 09:59 PM
On error goto 0 David Excel Programming 2 November 18th 03 01:43 PM


All times are GMT +1. The time now is 01:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"