Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel macro - Opening a sheet in accordance with the value in a particular cell

this is what i want to do.

the first sheet is named "SheetZero", in it the cell A1 contains
value which can vary between 1 and 20. SheetZero also contains a butto
with a macro assigned to it.

additionally there are twenty more sheets named Sheet1, Sheet2, ..
etc., to Sheet20.

when the value in cell A1 in SheetZero is changed, and the macro i
activated by clicking the button, i want another sheet to be opened, i
such a manner that it is based on the value in cell A1.

if the value is 1, then Sheet1 should open. if the value is 2, the
Sheet2 should open. if the value is 3, then Sheet3 should open... so o
and so forth ... if the value is 20, then Sheet20 should open.

please help me with the VB code for the macro. i am a novice in macr
writing, so please help me accordingly.

thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Excel macro - Opening a sheet in accordance with the value in a particular cell

Hi
try something like
Worksheets("Sheet" & activesheet.range
("A1").value).activate

-----Original Message-----
this is what i want to do.

the first sheet is named "SheetZero", in it the cell A1

contains a
value which can vary between 1 and 20. SheetZero also

contains a button
with a macro assigned to it.

additionally there are twenty more sheets named Sheet1,

Sheet2, ...
etc., to Sheet20.

when the value in cell A1 in SheetZero is changed, and

the macro is
activated by clicking the button, i want another sheet to

be opened, in
such a manner that it is based on the value in cell A1.

if the value is 1, then Sheet1 should open. if the value

is 2, then
Sheet2 should open. if the value is 3, then Sheet3 should

open... so on
and so forth ... if the value is 20, then Sheet20 should

open.

please help me with the VB code for the macro. i am a

novice in macro
writing, so please help me accordingly.

thanks.


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel macro - Opening a sheet in accordance with the value in a particular cell

Hi

you could add this bit of code to the buttons click event

either one or the other

Code:
--------------------

Dim mySheet As Integer
'get value from Cell A1
mySheet = Range("A1").Value
'activates the sheet by position
Worksheets(mySheet + 1).Activate

'or you could do it this way
Dim MySheetName As String
'get name of sheet
MySheetName = "sheet" & Range("A1").Value
'open the sheet by name
Worksheets(MySheetName).Activate

--------------------



HTH

David


---
Message posted from http://www.ExcelForum.com/

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
Excel 2007-macro enabled, multi-sheet opening in minimized mode LT Excel Discussion (Misc queries) 0 March 11th 10 05:36 PM
Excel blank sheet opening but the sheet has data DeeMocz8 Excel Discussion (Misc queries) 0 March 11th 09 06:43 PM
Opening at specific cell - No Macro TexJen09 Excel Discussion (Misc queries) 0 November 21st 08 05:49 PM
opening sheet, next available cell displayed Stephen New Users to Excel 2 January 5th 07 04:49 PM
Opening an excel sheet but i don't see it Erwin Excel Discussion (Misc queries) 2 February 17th 05 02:00 AM


All times are GMT +1. The time now is 12:28 AM.

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"