ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referencing Worksheet code name in the following code (https://www.excelbanter.com/excel-programming/388121-referencing-worksheet-code-name-following-code.html)

Barb Reinhardt

Referencing Worksheet code name in the following code
 
I am opening oWB and need to reference a worksheet code name in oWB. I have
the following:

Set oRevisionWS = Nothing
On Error Resume Next
oWB.Activate
oRevisionWS = Revisions <~~~worksheet code name
On Error GoTo 0

I need to know how to define oRevisionWS to be the worksheet with the code
name Revisions.

Thanks,
Barb Reinhardt

Jim Rech

Referencing Worksheet code name in the following code
 
Sub a()
Dim WS As Worksheet
Dim oRevisionWS As Worksheet
For Each WS In Worksheets
If WS.CodeName = "Revisions" Then
Set oRevisionWS = WS
Exit For
End If
Next
If Not oRevisionWS Is Nothing Then MsgBox oRevisionWS.Name
End Sub


--
Jim
"Barb Reinhardt" wrote in message
...
|I am opening oWB and need to reference a worksheet code name in oWB. I
have
| the following:
|
| Set oRevisionWS = Nothing
| On Error Resume Next
| oWB.Activate
| oRevisionWS = Revisions <~~~worksheet code name
| On Error GoTo 0
|
| I need to know how to define oRevisionWS to be the worksheet with the code
| name Revisions.
|
| Thanks,
| Barb Reinhardt



Barb Reinhardt

Referencing Worksheet code name in the following code
 
Thanks. This is one I just can't seem to remember how to do.

"Jim Rech" wrote:

Sub a()
Dim WS As Worksheet
Dim oRevisionWS As Worksheet
For Each WS In Worksheets
If WS.CodeName = "Revisions" Then
Set oRevisionWS = WS
Exit For
End If
Next
If Not oRevisionWS Is Nothing Then MsgBox oRevisionWS.Name
End Sub


--
Jim
"Barb Reinhardt" wrote in message
...
|I am opening oWB and need to reference a worksheet code name in oWB. I
have
| the following:
|
| Set oRevisionWS = Nothing
| On Error Resume Next
| oWB.Activate
| oRevisionWS = Revisions <~~~worksheet code name
| On Error GoTo 0
|
| I need to know how to define oRevisionWS to be the worksheet with the code
| name Revisions.
|
| Thanks,
| Barb Reinhardt





All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com