View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mart Mart is offline
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