Thread: Excel Ranges
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ian Wilson Ian Wilson is offline
external usenet poster
 
Posts: 1
Default Excel Ranges

Hello Excel Experts.

How can I perameterise this code so it selects the row
and column of whichever cell I click on?

As the code stands it will only work if I click on C4 or
D13. Thanks for your help.

Private Sub Worksheet_SelectionChange(ByVal Target As
Range)


Dim CurrRow, CurrCol

CurrRow = ActiveCell.Row ' Get Row.
CurrCol = ActiveCell.Column ' Get Column.

If CurrRow = 4 And CurrCol = 3 Then
Range("4:4,C:C").Select
Range("C1").Activate
End If

If CurrRow = 13 And CurrCol = 4 Then
Range("13:13,D:D").Select
Range("D1").Activate
End If

End Sub