![]() |
Select specific columns for a given cell selection
I want to select the first four columns ("A:D") of what ever row the user
selects a cell in, using a "Selection_Change" event. So if I click cell A4, cells A4:D4 are selected. Likewise, if I click cell C4, cells A4:D4 are selected. Sure it's an easy script that I've just overlooked, but could use someone's help. Thanks, Mike |
Select specific columns for a given cell selection
try this...
Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error GoTo ErrorHandler Application.EnableEvents = False If Target.Column <= 4 Then Range(Cells(Target.Row, 1), Cells(Target.Row, 4)).Select End If ErrorHandler: Application.EnableEvents = True End Sub HTH "crazybass2" wrote: I want to select the first four columns ("A:D") of what ever row the user selects a cell in, using a "Selection_Change" event. So if I click cell A4, cells A4:D4 are selected. Likewise, if I click cell C4, cells A4:D4 are selected. Sure it's an easy script that I've just overlooked, but could use someone's help. Thanks, Mike |
Select specific columns for a given cell selection
Thank you Jim. This was a great help. Knew it was something fairly simple.
Mike "Jim Thomlinson" wrote: try this... Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error GoTo ErrorHandler Application.EnableEvents = False If Target.Column <= 4 Then Range(Cells(Target.Row, 1), Cells(Target.Row, 4)).Select End If ErrorHandler: Application.EnableEvents = True End Sub HTH "crazybass2" wrote: I want to select the first four columns ("A:D") of what ever row the user selects a cell in, using a "Selection_Change" event. So if I click cell A4, cells A4:D4 are selected. Likewise, if I click cell C4, cells A4:D4 are selected. Sure it's an easy script that I've just overlooked, but could use someone's help. Thanks, Mike |
All times are GMT +1. The time now is 03:39 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com