VBA clear rows from a reference cell

Russk68

Well-known Member
Joined
May 1, 2006
Messages
589
Office Version
  1. 365
Platform
  1. MacOS
Hello all,
I need to clear a range of cells based on a reference cell.

O5 would be the reference cell. O5 will have a dropdown list ("Clear" & "Select") and when "Clear" is selected, A pop up message: "Are you sure?"
Yes, A5,C5:N5 contents cleared. (B5 is a hidden helper column)
C5,E5,G5,I5,K5,M5= "Spare" (Each cell prints "Spare")
O5 goes back to "Select"
Select C5
End.

I would like the macro to work the same when O9 is the dropdown list ("Clear") and all above applies to row 9.

So, anywhere "Clear" is selected in column O, the same row will show the results of the macro.

Any help is greatly appreciated!

Russ
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
How about
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Target.Column = 15 Then Exit Sub
   If Target.Value = "Clear" Then
      Application.EnableEvents = False
      Intersect(Target.EntireRow, Range("A:A,C:N")).ClearContents
      Intersect(Target.EntireRow, Range("C:C,E:E,G:G,I:I,K:K,M:M")).Value = "Spare"
      Target.Value = "Select"
      Application.EnableEvents = True
   End If
End Sub
This will work for all cells in col O.
 
Upvote 0
Thank you very much! I appreciate your time on this!
 
Upvote 0

Forum statistics

Threads
1,215,564
Messages
6,125,579
Members
449,237
Latest member
Chase S

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