VBA code - Specify cell rather than entire column

phmalu

Board Regular
Joined
Jun 21, 2017
Messages
52
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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,213,482
Messages
6,113,916
Members
448,533
Latest member
thietbibeboiwasaco

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