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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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