Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Looking for worksheet according to name in cell

Hi, Just a quickie (I hope)
I have a cell that has been given a range name (Reg_no) How can a Worksheet
be selected according to the info within the Ranged cell?
The workbook has many tabs, and what I want is a piece of code that will
take me to the tab with the same name that is within the Ranged cell.
Help greatly appreciated
John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Looking for worksheet according to name in cell

Right click sheet tabview codecopy/paste thistype the name of the sheet
into a cell and double click on it

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.DisplayAlerts = False
Dim WantedSheet As String
WantedSheet = Trim(ActiveCell.Value)
If WantedSheet = "" Then Exit Sub
On Error Resume Next
If Sheets(ActiveCell.Value) Is Nothing Then
GetWorkbook ' calls another macro to do that
Else
Application.Goto Sheets(ActiveCell.Value).Range("a4")
End If
Application.DisplayAlerts = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"JohnUK" wrote in message
...
Hi, Just a quickie (I hope)
I have a cell that has been given a range name (Reg_no) How can a
Worksheet
be selected according to the info within the Ranged cell?
The workbook has many tabs, and what I want is a piece of code that will
take me to the tab with the same name that is within the Ranged cell.
Help greatly appreciated
John


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Looking for worksheet according to name in cell

Hi Don, Many thanks for your help.
I tried the code below and it works a treat on its own, but is there some
way I can incorporate it into an existing macro, because the rest of the
macro copies data from the main tab and needs to know what tab to paste it
to.
Thanks


"Don Guillett" wrote:

Right click sheet tabview codecopy/paste thistype the name of the sheet
into a cell and double click on it

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.DisplayAlerts = False
Dim WantedSheet As String
WantedSheet = Trim(ActiveCell.Value)
If WantedSheet = "" Then Exit Sub
On Error Resume Next
If Sheets(ActiveCell.Value) Is Nothing Then
GetWorkbook ' calls another macro to do that
Else
Application.Goto Sheets(ActiveCell.Value).Range("a4")
End If
Application.DisplayAlerts = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"JohnUK" wrote in message
...
Hi, Just a quickie (I hope)
I have a cell that has been given a range name (Reg_no) How can a
Worksheet
be selected according to the info within the Ranged cell?
The workbook has many tabs, and what I want is a piece of code that will
take me to the tab with the same name that is within the Ranged cell.
Help greatly appreciated
John



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Looking for worksheet according to name in cell

Ah - I have it, and thanks to you.
I used the:
Application.Goto Sheets(ActiveCell.Value).Range("B2")
Many thanks Don

Take care
John

"JohnUK" wrote:

Hi Don, Many thanks for your help.
I tried the code below and it works a treat on its own, but is there some
way I can incorporate it into an existing macro, because the rest of the
macro copies data from the main tab and needs to know what tab to paste it
to.
Thanks


"Don Guillett" wrote:

Right click sheet tabview codecopy/paste thistype the name of the sheet
into a cell and double click on it

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.DisplayAlerts = False
Dim WantedSheet As String
WantedSheet = Trim(ActiveCell.Value)
If WantedSheet = "" Then Exit Sub
On Error Resume Next
If Sheets(ActiveCell.Value) Is Nothing Then
GetWorkbook ' calls another macro to do that
Else
Application.Goto Sheets(ActiveCell.Value).Range("a4")
End If
Application.DisplayAlerts = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"JohnUK" wrote in message
...
Hi, Just a quickie (I hope)
I have a cell that has been given a range name (Reg_no) How can a
Worksheet
be selected according to the info within the Ranged cell?
The workbook has many tabs, and what I want is a piece of code that will
take me to the tab with the same name that is within the Ranged cell.
Help greatly appreciated
John



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Looking for worksheet according to name in cell

Glad you got it sorted


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"JohnUK" wrote in message
...
Ah - I have it, and thanks to you.
I used the:
Application.Goto Sheets(ActiveCell.Value).Range("B2")
Many thanks Don

Take care
John

"JohnUK" wrote:

Hi Don, Many thanks for your help.
I tried the code below and it works a treat on its own, but is there some
way I can incorporate it into an existing macro, because the rest of the
macro copies data from the main tab and needs to know what tab to paste
it
to.
Thanks


"Don Guillett" wrote:

Right click sheet tabview codecopy/paste thistype the name of the
sheet
into a cell and double click on it

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As
Boolean)
Application.DisplayAlerts = False
Dim WantedSheet As String
WantedSheet = Trim(ActiveCell.Value)
If WantedSheet = "" Then Exit Sub
On Error Resume Next
If Sheets(ActiveCell.Value) Is Nothing Then
GetWorkbook ' calls another macro to do that
Else
Application.Goto Sheets(ActiveCell.Value).Range("a4")
End If
Application.DisplayAlerts = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"JohnUK" wrote in message
...
Hi, Just a quickie (I hope)
I have a cell that has been given a range name (Reg_no) How can a
Worksheet
be selected according to the info within the Ranged cell?
The workbook has many tabs, and what I want is a piece of code that
will
take me to the tab with the same name that is within the Ranged cell.
Help greatly appreciated
John




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
Linking Tab/worksheet names to a worksheet cell LinLin Excel Discussion (Misc queries) 3 March 9th 09 03:31 PM
link a cell in the 'Master' worksheet list to a 'Detail' worksheet Paul Condron Excel Programming 12 July 16th 06 10:41 PM
error with macro to name new worksheet with cell from old worksheet Moon Excel Programming 4 November 14th 05 07:13 AM
How can I link cell colours from worksheet to worksheet/workbook? Evelyn Excel Worksheet Functions 1 July 5th 05 09:16 PM
selecting cell range in other worksheet without switching to worksheet suzetter[_4_] Excel Programming 4 June 22nd 05 08:55 PM


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