Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple worksheet selection question???


Hi all, How do i select a worksheet based on a cells contents?, if i
have cell A1 containg a dropdown list of all the worksheets Like Week1,
Week2 etc how do i create the code to call a work sheet based on that
name instead of Worksheets("Week1").Select, so something like
Sub weekselect()
Dim t As Worksheet
t.Name = Range("f10").Value
Worksheets(t).Visible=True
Worksheets(t).Select
Worksheets("Week Selection").Visible = False
End With
End Sub

Regards,
Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=552518

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Simple worksheet selection question???

Simon Lloyd wrote:
Hi all, How do i select a worksheet based on a cells contents?, if i
have cell A1 containg a dropdown list of all the worksheets Like
Week1, Week2 etc how do i create the code to call a work sheet based
on that name instead of Worksheets("Week1").Select, so something like
Sub weekselect()
Dim t As Worksheet
t.Name = Range("f10").Value
Worksheets(t).Visible=True
Worksheets(t).Select
Worksheets("Week Selection").Visible = False
End With
End Sub

Regards,
Simon


Try this:


--
Gordon Smith (eMVP)


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Simple worksheet selection question???

Simon Lloyd wrote:
Hi all, How do i select a worksheet based on a cells contents?, if i
have cell A1 containg a dropdown list of all the worksheets Like
Week1, Week2 etc how do i create the code to call a work sheet based
on that name instead of Worksheets("Week1").Select, so something like
Sub weekselect()
Dim t As Worksheet
t.Name = Range("f10").Value
Worksheets(t).Visible=True
Worksheets(t).Select
Worksheets("Week Selection").Visible = False
End With
End Sub

Regards,
Simon


Try this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Validation.Type = 3 Then
Sheets(Target.Value).Select
End If
End Sub


--
Gordon Smith (eMVP)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple worksheet selection question???


Gordon thanks for the reply, i didn't quite understand what the code wa
meant to do as it doesn't look to a cell for its information. M
situation is this, i have a front sheet with an autoshape button on i
next to that button is a cell with list validation in it, that lis
refers to week1, week2....etc these are the names of the worksheets,
want to be able to select one of these weeks in the dropdown then clic
my autoshape which will run the code and select the appropriat
worksheet and hide the front sheet.

Regards,
Simo

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=55251

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple worksheet selection question???


Sorted this one!.....seems like i was trying to use a sledgehammer to
crack a nut!!!

Simple when you take a break and come back to it!

Regards,
Simon

Sub weekselect()
t = Range("F10").Value
Worksheets(t).Visible = True
Worksheets(t).Select
Worksheets("Week Selection").Visible = False
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=552518



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Simple worksheet selection question???

Hi, Simon,
You could also try this

Private Sub Worksheet_Change(ByVal Target As Range)
Dim SheetName As Range
Set SheetName = Me.Range("SheetName")
Set Intersection = Intersect(Target, SheetName)
If Not Intersection Is Nothing Then
If Target.Validation.Type = 3 Then
Sheets(Target.Value).Select
End If
End If
End Sub

Make sure it is pasted into the codepage for the worksheet that contains
your list, not a normal code module.

It relies on the cell containing your dropdown list being called "SheetName"
If you do it like this, tou won't need to select from the list then click a
button, the code will do it all for you in one go.

It also checks that the change is being made to the "Sheetname" cell - if a
change to any other cell is made, the code won't run - otherwise, it would
try to activate a worksheet with a name of whatever you typed into ANY cell.

Cheers

Pete



"Simon Lloyd" wrote:


Sorted this one!.....seems like i was trying to use a sledgehammer to
crack a nut!!!

Simple when you take a break and come back to it!

Regards,
Simon

Sub weekselect()
t = Range("F10").Value
Worksheets(t).Visible = True
Worksheets(t).Select
Worksheets("Week Selection").Visible = False
End Sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=552518


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
Quick VBA Worksheet Change Event or Selection Question: Damil4real Excel Worksheet Functions 6 November 17th 09 10:28 PM
IF formula-simple question; simple operator Rich D Excel Discussion (Misc queries) 4 December 6th 07 03:36 PM
Simple selection, but hey, I'm no guru!! Director Excel Worksheet Functions 1 August 18th 05 01:56 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
Simple Selection Macro Jason Excel Programming 3 October 9th 04 09:52 AM


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