Question for Worksheet Change in Excel

Joe2000

New Member
Joined
Oct 25, 2023
Messages
3
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hello I am new in Excel and I would thank a lot if someone can help me.
I wrote this code with linked dropdown lists in cells:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$S$4" Then
Range("$T$4").Value = Empty
End If

If Target.Address = "$S$5" Then
Range("$T$5").Value = Empty
End If

If Target.Address = "$S$6" Then
Range("$T$6").Value = Empty
End If
End Sub


I need to do the same process till the end of the worksheet (for example S7 with T7, S8 with T8, S9 with T9 and so on) but I do not know how to do it without writing one by one. Can someone Kindly help me please?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
This could be a solution:
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row < 4 Or Target.Column <> 19 Then Exit Sub '19="S"    'accept only cells from S4 and down
    Application.EnableEvents = False              'avoid redundant triggering of Worksheet_Change
    Target.Offset(0, 1) = Empty                   'empty same row, one column right "T"
    Application.EnableEvents = True
End Sub
 
Upvote 1
Solution
This could be a solution:
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row < 4 Or Target.Column <> 19 Then Exit Sub '19="S"    'accept only cells from S4 and down
    Application.EnableEvents = False              'avoid redundant triggering of Worksheet_Change
    Target.Offset(0, 1) = Empty                   'empty same row, one column right "T"
    Application.EnableEvents = True
End Sub
Thank you so much!!! you are a hero 🤗🙌
 
Upvote 0
Thanks for the positive feedback(y), glad having been of some help.
By the way, you probably need to mark this thread as 'Solved'.
 
Upvote 1

Forum statistics

Threads
1,224,813
Messages
6,181,117
Members
453,021
Latest member
Justyna P

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