View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
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.