Changing a SelectionChange range

bademployee

Board Regular
Joined
Aug 19, 2010
Messages
184
I'm using the following routine, but Z only updates when A12:A21 are selected.

I need to change this so that A12:A21 change when any within the sheet is selected.


Code:
[FONT=Verdana]Private Sub Worksheet_SelectionChange(ByVal Target As Range)[/FONT]    
    
    Dim Cell    As Range
    Dim Rng     As Range
    
        If Target.Cells.Count > 1 Then Exit Sub
    
        Set Rng = Range("A12:A21")
    
        If Intersect(Target, Rng) Is Nothing Then Exit Sub
    
        Application.EnableEvents = False
        
            Set Cell = Cells(Target.Row, "Z")
        
            Select Case Target.Value
                Case Is = "UAN": Cell.Value = "Variable"
                Case Is = "": Cell.Value = ""
                Case Else: Cell.Value = "Fixed"
            End Select
            
        Application.EnableEvents = True
[FONT=Verdana]
End Sub[/FONT]

Thanks in advance

Mark
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Dim Cell    As Range
        If Target.Cells.Count > 1 Then Exit Sub
    
        Application.EnableEvents = False
        
            Set Cell = Cells(Target.Row, "Z")
        
            Select Case Target.Value
                Case Is = "UAN": Cell.Value = "Variable"
                Case Is = "": Cell.Value = ""
                Case Else: Cell.Value = "Fixed"
            End Select
            
        Application.EnableEvents = True

End Sub
 
Upvote 0
Try:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Dim Cell    As Range
        If Target.Cells.Count > 1 Then Exit Sub
    
        Application.EnableEvents = False
        
            Set Cell = Cells(Target.Row, "Z")
        
            Select Case Target.Value
                Case Is = "UAN": Cell.Value = "Variable"
                Case Is = "": Cell.Value = ""
                Case Else: Cell.Value = "Fixed"
            End Select
            
        Application.EnableEvents = True

End Sub

Thanks Joe, works perfectly!
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top