Select specific columns for a given cell selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top