Referencing Worksheet code name in the following code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
|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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top