automatically go to a cell (excel)

C

chbelair

For example, if cell a1 = b100, I would like to be able to double click on A1
and automatically go to cell b100.
 
D

Don Guillett

right click sheet tab>view code>insert this. Now if b100 is typed into the
active cell and you double click you will go there.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Range(Target).Select
End Sub
 
G

Gord Dibben

You mean if the value of A1 is same as value of B100 or if A1 contains the
formula =B100 ?

If the latter, go to Tools>Options>Edit and uncheck "edit directly in cell"

If the former you would need doubleclick event code.

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
On Error GoTo enditall
Application.EnableEvents = False
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Target.Value = Range("B100").Value Then
Range("B100").Select
End If
End If
enditall:
Application.EnableEvents = True
End Sub

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

Copy/paste the above into that sheet module.


Gord Dibben MS Excel MVP
 
Top