Automatically change cell value when another cells value change to 0

OX_2005

New Member
Joined
Feb 29, 2024
Messages
43
Office Version
  1. 365
Platform
  1. Windows
I am still very new to VBA and I am struggling with this. Any assistance will be helpful.

When the value in Column "M" changes to "0" I am wanting the values in columns "E:I" to automatically change to "FALSE" so that the check box will uncheck. I can get it do work with just 1 row of data but I am trying to get it to do a Range of rows (3 to 42).

This is the current code I put together

1709240096898.png


This is the Doc I am working with


1709240078039.png
 
So I have a follow-up question. If I wanted to have it do 2 different things when something is delete is that possible? Current code is what you gave me with a couple Cell locations. So if when I delete whats in cell A and it does the code below can I also have it delete the contents of cells B:E?



Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As Range
Dim cell As Range

' See if any values in column M were updated
Set rng = Intersect(Target, Range("A3:A42"))

' Exit if no cells in that range were updated
If rng Is Nothing Then Exit Sub

' Loop through cells in watched range can check their values
Application.EnableEvents = False
For Each cell In rng
' See if value is 0
If cell.Value = "" Then
' Update columns E through I
Range(Cells(cell.Row, "N"), Cells(cell.Row, "R")).Value = "FALSE"
End If
Next cell

Application.EnableEvents = True

End Sub
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
To delete the contents of cells B:E would just look something like:
VBA Code:
Range(Cells(cell.Row, "B"), Cells(cell.Row, "E")).ClearContents
 
Upvote 0
To delete the contents of cells B:E would just look something like:
VBA Code:
Range(Cells(cell.Row, "B"), Cells(cell.Row, "E")).ClearContents
Thank you I was so over thinking this. I want to thank you for all your help. I have hopefully finished this document now.
 
Upvote 0

Forum statistics

Threads
1,215,124
Messages
6,123,187
Members
449,090
Latest member
bes000

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