ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sheet names in VBE (https://www.excelbanter.com/excel-programming/281909-re-sheet-names-vbe.html)

Tom Ogilvy

Sheet names in VBE
 
In the project explorer, if your entries look like

A (Sheet1)
B (Sheet2)
C (Sheet3)

so that A, B and C are the codenames of the sheet.

Sub AAAABB()
Dim VC As Object
Dim i As Long
Dim varr(1 To 3)
i = 0
For Each VC In ThisWorkbook.VBProject.VBComponents
If VC.Type = vbext_ct_Document Then
Select Case LCase(VC.Name)
Case "a", "b", "c"
i = i + 1
varr(i) = VC.Properties("Name").Value
If i = 3 Then Exit For
End Select
End If
Next
Worksheets(varr).Select
Worksheets(varr(1)).Activate
End Sub

--
Regards,
Tom Ogilvy
Steve wrote in message
news:3fac1008$0$14371$afc38c87@...
Hi. I have the following code:

Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Sheets("Sheet1").Activate

I have named my sheets in the VBE to A, B and C. How do I rewrite the

above
code using the VBE names?

Thanks!






All times are GMT +1. The time now is 03:39 PM.

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