LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Trefor
 
Posts: n/a
Default Error 1004 using array in Sheet select.

If I select a sheet with its real name:

Sheets("Sheet1").Select - Works fine
Sheets(Array("Sheet1", "Sheet2")).Select - Works fine

If I assign the sheet name(s) to a constant

Public Const TSGSheet1 = "Sheet1"
Public Const TSGSheet2 = "Sheet2"

Sheets(TSGSheet1).Select - Works fine
Sheets(TSGSheet2).Select - Works fine

Sheets(Array(TSGSheet1, TSGSheet2)).Select - fails with Error 1004

My macro's/VBA do multiple Selects and rather than explicitly specifying the
sheet names in every command, I thought I would set up a constant, use the
constant in the multiple commands. If I then wanted to change the sheet name,
I could just change the constant assignment once.

Have I done something wrong? It would appear that you can not use constants
in an array?

--
Trefor
 
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
is it possible to select and change the values of cells in a minimized excel spread sheet from vba? Daniel Excel Worksheet Functions 6 July 11th 05 11:24 PM
Formula checking multiple worksheets sonic-the-mouse Excel Worksheet Functions 2 June 5th 05 07:48 PM
Formula checking multiple worksheets sonic-the-mouse Excel Worksheet Functions 2 June 5th 05 03:28 AM
Dynamic Formulas with Dynamic Ranges Ralph Howarth Excel Worksheet Functions 5 January 21st 05 08:44 AM
how can i select all the cells with same color on a sheet if there are multipale colors by vba code uobt Charts and Charting in Excel 1 December 15th 04 05:27 PM


All times are GMT +1. The time now is 09:15 AM.

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

About Us

"It's about Microsoft Excel"