Macro to increase all cells with a value that have a yes next to them by a certain number

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I need a macro that when its run will do the following
with active sheet

ceck there is a number in cell AK28, if not message box "Please enter a Number of Days"
exit
if there is then

Look at the range AK32:AK47
with each cell check if they have a value in them and that the next column has "no" in it.
only if both of these are correct increase the value in the cell by the number in AK28

so for example

AK28 = 30


AK33 = 100 & AL33 = "No" so Increase AK33 by 30 so AK33 =130
do this for all cells in the range but only if they match the above criteria otherwise leave how they are.

please help

Thanks

Tony
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Your thread title says increase cells that have "Yes" next to them, but the text of your question says "No", I've gone with "No" in the code so if it's wrong, that's all theat will need changing.
Code:
Option Explicit
Sub add_days()
Dim c As Range
If Range("AK28").Value <> "" Then
    For Each c In Range("AK32:AK47")
        If c.Value > 0 And c.Offset(, 1).Value = "No" Then c.Value = c.Value + Range("AK28").Value
    Next
Else
    MsgBox "Please enter number of days"
End If
End Sub
 
Upvote 0
jasonb75 Thank you for your help,
I wanted "No" sorry for the confusion, all seam to work great thank you :-)
Tony
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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