View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
DSC[_12_] DSC[_12_] is offline
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/