Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to select entire row and column in a sigle cell selection sabu varoor Excel Worksheet Functions 3 December 22nd 08 05:19 PM
Select last cell in Selection jlclyde Excel Discussion (Misc queries) 4 June 27th 08 09:23 PM
I need a specific value in auto filter to fill a combo box and than match the select value in 2 other columns. Marc Excel Worksheet Functions 0 May 22nd 06 08:41 PM
Lock data in a cell a specific cell based on selection on other ce CrimsonPlague29 Excel Worksheet Functions 0 May 10th 06 11:06 AM
Select specific cell Shawn Excel Discussion (Misc queries) 1 April 28th 05 09:00 PM


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"