LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Sheet number variable

When writting code you need to avoid key words such as worksheet or sheet
which are names of objects, properties, events etc.

This can be easily done by using prefixes for your variables to describe the
variable type e.g str for string, d for date, int for integer.

So try

intSheet = Range("ShCount")
Sheets(intSheet).Select

Rgds

M.

"mikey10" wrote:


Hi

Quite a simple problem really, but I just cant seem to figure ut out. I
have a simple variable in a cell called "ShCount". I would like to write
a macro that selects the sheet number that relates to the number in cell
'ShCount'. This is the code so far and the second line is not accepted.

Sheet = Range("ShCount")
Sheets(Sheet).Select

Any idea what I am missing?

Many thanks in advance
Mike


--
mikey10
------------------------------------------------------------------------
mikey10's Profile: http://www.excelforum.com/member.php...o&userid=15378
View this thread: http://www.excelforum.com/showthread...hreadid=270084


 
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
Add sheet name into a variable. Richhall[_2_] Excel Worksheet Functions 1 September 18th 09 12:11 PM
How To make a sheet reference Variable (eq: sum(sheet!D2:H2)) John Linker Excel Discussion (Misc queries) 3 June 16th 08 11:29 PM
Variable sheet and Formula Sheet Emmett423 Excel Discussion (Misc queries) 2 March 31st 06 02:14 AM
variable in a link where the variable is the name of the sheet darrelly Excel Worksheet Functions 1 October 7th 05 08:24 AM
Using a variable as a Row number Phil Hennessy Excel Programming 3 August 6th 04 05:56 PM


All times are GMT +1. The time now is 09:43 PM.

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"