Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default VBA question about selecting worksheets

I am writting some code and i am stuck on how to select a worksheet.
There is a month listed in cell A1 of Sheet1. It is a validated cell
to select months. The rest of the Sheets are labeled named with
months ie. January, February ... Based on what is in cell A1 on
Sheet1, I woudl like the code to select the corresponding sheet. Any
guidance at all woudl be appreciated.

Here is what I ahve so far and it does not work at all.

Sub Tryingsomething()
Dim date1 As String
date1 = Sheet1.Range("A1")
Worksheets(date1).Range("A1").Select
End Sub

Jay
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default VBA question about selecting worksheets

You could use the following code:

Sub GoWhere()

Dim ws As Worksheet
Dim strMonth As String

Set ws = ThisWorkbook.Sheets(1)

strMonth = ws.Range("A1").Value

Select Case strMonth
Case "January", "February", "March", _
"April", "May", "June", "July", _
"August", "September", "October", _
"November", "December"
ThisWorkbook.Sheets(strMonth).Activate
ActiveSheet.Range("A1").Select
Case Else
End Select

Set ws = Nothing

End Sub

--
Kevin Backmann


"jlclyde" wrote:

I am writting some code and i am stuck on how to select a worksheet.
There is a month listed in cell A1 of Sheet1. It is a validated cell
to select months. The rest of the Sheets are labeled named with
months ie. January, February ... Based on what is in cell A1 on
Sheet1, I woudl like the code to select the corresponding sheet. Any
guidance at all woudl be appreciated.

Here is what I ahve so far and it does not work at all.

Sub Tryingsomething()
Dim date1 As String
date1 = Sheet1.Range("A1")
Worksheets(date1).Range("A1").Select
End Sub

Jay

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default VBA question about selecting worksheets

Sub Tryingsomething()
Sheets(Sheets("Sheet1").Range("A1").Value).Activat e
Range("A1").Select
End Sub
--
Gary''s Student - gsnu200779
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default VBA question about selecting worksheets

On Apr 17, 10:17*am, Gary''s Student
wrote:
Sub Tryingsomething()
Sheets(Sheets("Sheet1").Range("A1").Value).Activat e
Range("A1").Select
End Sub
--
Gary''s Student - gsnu200779


Thanks,
this is eactly what I was looking for. I always seem to forget to
activate the sheet before selecting something on it.
Thanks again,
Jay
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
selecting cells in different worksheets Kaitlin.uk Excel Discussion (Misc queries) 2 January 17th 07 04:46 PM
Comment BUG- selecting cells on other worksheets CFD Excel Discussion (Misc queries) 3 March 6th 06 07:04 AM
Selecting and viewing sum in status bar across worksheets JMS Excel Discussion (Misc queries) 2 July 15th 05 02:28 PM
Selecting and summing across worksheets JMS Excel Discussion (Misc queries) 2 July 15th 05 01:06 AM
Selecting across worksheets JMS Excel Discussion (Misc queries) 1 July 14th 05 10:44 PM


All times are GMT +1. The time now is 11:51 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"