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