Target.offset

  • Thread starter Thread starter trussman
  • Start date Start date
T

trussman

Help please.. This works but, I want to be able to double click
anywhere in the same row and activate the same target(in column 2). I
currently have 223 columns.
Is this possible?



Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Cancel = True

Worksheets(Target.Offset(0, -15).Value).Activate

End Sub



Thanks in advance,

Marc
 
Hi

if you always just want to active the cell in column B of whatever row
you're in try

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Target.Offset(0, 2 - Target.Column()).Activate
End Sub


Cheers
JulieD
 
Thank you for the reply,

Well actually I need it to activate the sheet of the employee name in
column 2 by double clicking in any cell in the row of that employee.

Thanks, Marc
 
Hi Marc

in that case just use

Worksheets(Target.Offset(0, 2 - Target.Column()).Value).Activate

Cheers
JulieD
 
trussman said:
Help please.. This works but, I want to be able to double click
anywhere in the same row and activate the same target(in column 2). I
currently have 223 columns.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Cancel = True
Worksheets(Target.Offset(0, -15).Value).Activate
End Sub

How about
Cells(Target.Row, 2).Select
(If you have a single-cell selection, I think 'select'
is preferable to 'activate'.)
 
Back
Top