VBA code - Specify cell rather than entire column

phmalu

New Member
Joined
Jun 21, 2017
Messages
48
Office Version
  1. 2019
Platform
  1. Windows
Hello all
Any idea on how could I change this VBA code:
(it clears certain cells content whenever a drop-down is changed in column 19/S)
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
   If Target.Column = 19 Then
   If Target.Validation.Type = 3 Then
   Application.EnableEvents = False
   Target.Offset(0, 1).ClearContents
   Range(Target.Offset(0, -17), _
        Target.Offset(20, -17)).ClearContents
   Range(Target.Offset(24, -17), _
        Target.Offset(44, -17)).ClearContents
   Range(Target.Offset(48, -17), _
        Target.Offset(68, -17)).ClearContents
   End If
End If

exitHandler:
  Application.EnableEvents = True
  Exit Sub
    
End Sub
So that instead of specifying the column
VBA Code:
If Target.Column = 19 Then
I could specify the exact cell?
I've tried something like
VBA Code:
If Target.Address = "S2" Then
but not surprisingly it did not work since my VBA skills are quite limited

Thank you!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Watch MrExcel Video

Forum statistics

Threads
1,130,119
Messages
5,640,219
Members
417,131
Latest member
Seanr19871

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
Top