Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / March 2008

Tip: Looking for answers? Try searching our database.

Got to 0 - I do not understand - suggestions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
inarobis@gmail.com - 26 Mar 2008 23:55 GMT
Hello,

Someone can help me on this error to 0

So I have a little sub that copy several times the same sheet (Sheet 2
--> Template) according to the number of name in the rngRange (range)
in sheet1

For example, if I have three names in range rngRange (Report1,
Report2, and Report3) then it will copy three times the sheet2 and I
will rename it accordingly report1, report2 and report3

I am getting Err 0 problem, I could resolve on putting On Error GoTo 0
in the end of the sub.  Someone can help me on understanding this
issue :) ?

Ina

'---------------------------------------------------------------------------------------------
Public Sub CreateReportRange()
On Error GoTo CreateReportRange_Err

Dim strSheetName As String
Dim rngCell As Range

If ActiveWorkbook Is Nothing Then Exit Sub

Sheets("Sheet1").Select

For Each rngCell In Range("rngRange").Cells
   strSheetName = rngCell
   Sheets("Sheet2").Copy After:=Sheets("Sheet2")
   ActiveSheet.name = strSheetName
Next rngCell

CreateReportRange_Err:
MsgBox "CreateReportRange_Err " & Err.Description & " " & Err.Number
End Sub

'---------------------------------------------------------------------------------------------------------------
Jim Cone - 27 Mar 2008 00:16 GMT
Ina,
You forget the "Exit Sub" ahead of the error handler...
'--
Next rngCell
Exit Sub
CreateReportRange_Err:
'--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

<inarobis@gmail.com>
wrote in message
Hello,
Someone can help me on this error to 0
So I have a little sub that copy several times the same sheet (Sheet 2
--> Template) according to the number of name in the rngRange (range)
in sheet1
For example, if I have three names in range rngRange (Report1,
Report2, and Report3) then it will copy three times the sheet2 and I
will rename it accordingly report1, report2 and report3

I am getting Err 0 problem, I could resolve on putting On Error GoTo 0
in the end of the sub.  Someone can help me on understanding this
issue :) ?
Ina
'---
Public Sub CreateReportRange()
On Error GoTo CreateReportRange_Err

Dim strSheetName As String
Dim rngCell As Range

If ActiveWorkbook Is Nothing Then Exit Sub

Sheets("Sheet1").Select

For Each rngCell In Range("rngRange").Cells
   strSheetName = rngCell
   Sheets("Sheet2").Copy After:=Sheets("Sheet2")
   ActiveSheet.name = strSheetName
Next rngCell

CreateReportRange_Err:
MsgBox "CreateReportRange_Err " & Err.Description & " " & Err.Number
End Sub
Tyro - 27 Mar 2008 00:23 GMT
When the For statement finishes it drops into the error handler. You have to
Exit Sub when the For statement is done

Tyro

> Hello,
>
[quoted text clipped - 36 lines]
>
> '---------------------------------------------------------------------------------------------------------------
inarobis@gmail.com - 27 Mar 2008 09:05 GMT
> When the For statement finishes it drops into the error handler. You have to
> Exit Sub when the For statement is done
[quoted text clipped - 47 lines]
>
> - Show quoted text -

thanks guys :D

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.