Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to click a cell with mouse and have a different tab appear

I was wondering if there is a way where I can click say cell A1 which
currently has the text 'Tuesday' in it. By clicking on this cell, the user
is directed to a new tab (which the user has labelled as Tuesday).

My knowledge is somewhat limited. I know I can run a macro and then press
<CTRL and the short cut key, but I was hoping to be able to just use the
mouse and click on the cell to direct me to the new tab.

Any suggestions would be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default How to click a cell with mouse and have a different tab appear

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "A1" '<== change to suit
Dim sh As Worksheet

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

On Error Resume Next
If Not Me.Parent.Worksheets(.Value) Is Nothing Then

Me.Parent.Worksheets(.Value).Activate
End If
End With
End If

End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
__________________________________
HTH

Bob

"Randy Carriere" <Randy wrote in message
...
I was wondering if there is a way where I can click say cell A1 which
currently has the text 'Tuesday' in it. By clicking on this cell, the
user
is directed to a new tab (which the user has labelled as Tuesday).

My knowledge is somewhat limited. I know I can run a macro and then press
<CTRL and the short cut key, but I was hoping to be able to just use the
mouse and click on the cell to direct me to the new tab.

Any suggestions would be greatly appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default How to click a cell with mouse and have a different tab appear

I would be inclined to use double click. It is hard to accidentally double
click a cell. Here is some code for you. Right click the sheet tab you want
this to work in and select View Code. Paste the following...
It works on double clicking cells A1 or A2 and takes you to the sheet named
in the cell.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Dim wks As Worksheet

If Not Intersect(Target, Me.Range("A1:A2")) Is Nothing Then
Cancel = True
On Error Resume Next
Set wks = Sheets(Target.Value)
On Error GoTo 0
If wks Is Nothing Then
MsgBox "Sheet " & Target.Value & " does not exist."
Else
wks.Select
End If
End If
End Sub
--
HTH...

Jim Thomlinson


"Randy Carriere" wrote:

I was wondering if there is a way where I can click say cell A1 which
currently has the text 'Tuesday' in it. By clicking on this cell, the user
is directed to a new tab (which the user has labelled as Tuesday).

My knowledge is somewhat limited. I know I can run a macro and then press
<CTRL and the short cut key, but I was hoping to be able to just use the
mouse and click on the cell to direct me to the new tab.

Any suggestions would be greatly appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default How to click a cell with mouse and have a different tab appear

Doubleclick event code could work.

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
'Substitute your cells/sheetnames
Select Case Target.Address(False, False)
Case "A1"
Sheets(Target.Value).Select
Case "A2"
Sheets(Target.Value).Select
Case "A3"
Sheets(Target.Value).Select
End Select
Cancel = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste into that sheet module.


Gord Dibben MS Excel MVP

On Thu, 19 Jun 2008 13:26:02 -0700, Randy Carriere <Randy
wrote:

I was wondering if there is a way where I can click say cell A1 which
currently has the text 'Tuesday' in it. By clicking on this cell, the user
is directed to a new tab (which the user has labelled as Tuesday).

My knowledge is somewhat limited. I know I can run a macro and then press
<CTRL and the short cut key, but I was hoping to be able to just use the
mouse and click on the cell to direct me to the new tab.

Any suggestions would be greatly appreciated.


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
Edit cell by using mouse - right click Michelle Excel Discussion (Misc queries) 1 March 3rd 10 09:23 PM
Format Cell with Mouse Click Ken[_25_] Excel Programming 11 September 3rd 06 09:19 PM
Opening a URL in a cell without a mouse click trountree Excel Discussion (Misc queries) 0 October 5th 05 04:41 PM
Add cell value with mouse click cbrasted Excel Discussion (Misc queries) 4 April 27th 05 01:36 AM
get value of a cell with a mouse click Ken Wright Excel Programming 0 July 22nd 03 07:15 PM


All times are GMT +1. The time now is 09:29 PM.

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"