View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Help! Selecting a Worksheet with VBA

This is working OK

Add also the sheet name to the name string
sheet(Name).select

you forgot the s


Dim Name As String
Name = Sheets("Sheet1").Range("A1").Value

Sheets(Name).Select


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message oups.com...
Hello,

Ok we all know that I can select a sheet on Excel by doing:
sheets("Name").select or worksheets("Name").select

But my problem is that I take the name from a cell with something like:

Dim Name as String
Name = Range("A1").value

If I now do:
sheet(Name).select

I get an error (Name as to be an Object, not a string). I can I do
this? It shouldn't be that hard to select a sheet from a cell value!

Damm VBA!

Regards,

Yona