Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Use VBE Sheet names in code

Same answer as on the 8th.
Was there a problem?

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:3fafb7d9$0$22362$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!





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
using the Excel generic worksheet names instead of user-given names in code Paul Excel Discussion (Misc queries) 5 June 26th 09 08:44 PM
Code names for excel sheets alan82 Excel Discussion (Misc queries) 5 April 21st 09 01:52 PM
Getting & Using Sheet Names or Index in VBA code rwjack New Users to Excel 4 April 14th 08 01:50 PM
Cell names = sheet names Vince Excel Worksheet Functions 9 February 8th 08 03:59 PM
Sheet names code Jonah Excel Discussion (Misc queries) 8 November 4th 06 03:03 AM


All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"