Automatically change cell value when another cells value change to 0

OX_2005

New Member
Joined
Feb 29, 2024
Messages
45
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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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