How To clear cell if cell another cell has "No.

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
Hi hope you can help, I have a cell X2 where you have a dropdown box with yes or no, if no is selected I want this to clear the cell in U2, how do this can you help me please? I am still fairly new to this and still learning.
 
Hi thanks. I have x2 private subs with the same name though. How would I add to the one I already have?
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
What's the code you already have?
 
Upvote 0
hi the other code is
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, Rw As Range

  Set Changed = Intersect(Target, Union(Range("H:H"), Range("H:H")))
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each Rw In Changed.Rows
      Cells(Rw.Row, "Q").Value = Environ("Username")
      Cells(Rw.Row, "R").Value = Now
      Cells(Rw.Row, "R").NumberFormat = "dd/mm/yyyy hh:mm"
    Next Rw
    Application.EnableEvents = True
  End If
  
End Sub
 
Upvote 0
try
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim Rw As Range
   
   If Not Intersect(Target, Range("H:H")) Is Nothing Then
      Application.EnableEvents = False
      For Each Rw In Target.Rows
         Cells(Rw.Row, "Q").Value = Environ("Username")
         Cells(Rw.Row, "R").Value = Now
         Cells(Rw.Row, "R").NumberFormat = "dd/mm/yyyy hh:mm"
      Next Rw
   ElseIf Target.Address(0, 0) = "AA5" Then
      If LCase(Target.Value) = "cancel all" Then
         Range("T5").Clear
      ElseIf LCase(Target.Value) = "cancel 1" Then
         Range("T5").Value = Range("T5").Value - 1
      End If
   End If
   Application.EnableEvents = True
End Sub
 
Upvote 0
thank you I will try that, please can you advise for future reference if I come across this again and I need to add extra to this sub how will I do it?
 
Upvote 0
In much the same way as i did above. ;)
 
Upvote 0
hi thank you, I have just changed the code a little by extending the range but it came back with an error, it didnt like the s5:v5 range as want it to check 5 cells as a number will be in one of those, can you help please?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim Rw As Range
   
   If Not Intersect(Target, Range("H:H")) Is Nothing Then
      Application.EnableEvents = False
      For Each Rw In Target.Rows
         Cells(Rw.Row, "Q").Value = Environ("Username")
         Cells(Rw.Row, "R").Value = Now
         Cells(Rw.Row, "R").NumberFormat = "dd/mm/yyyy hh:mm"
      Next Rw
   ElseIf Target.Address(0, 0) = "AA5" Then
      If LCase(Target.Value) = "cancel all" Then
         Range("S5:V5").Clear
      ElseIf LCase(Target.Value) = "cancel 1" Then
         Range("S5:V5").Value = Range("S5:V5").Value - 1
      End If
   End If
   Application.EnableEvents = True
End Sub
 
Upvote 0
Is this the last change that you are going to request, before I re-write it again?
 
Upvote 0
Do you want to change the value in all cells from S5 to V5?
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,181
Members
448,871
Latest member
hengshankouniuniu

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