Add to Cell Value based on another cell

csrloddidadesigns

New Member
Joined
Oct 24, 2017
Messages
2
Hello. New here. Requesting help on the following task. I need to add a value to the number in column D based on the value of column A. For example...

Before the VBA based on column A value, so if column A is like Q10, it will add $10 and if column A if like anything else, it will add $20. I've tried many iterations of if then else code found on here, but end up with no change or with a runaway code. Thanks in advance for you help.


Column A..............Column D
Q10 $10
A10 $10

After the VBA

Q10 $20
A10 $30
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
a vba solution

Code:
Option Explicit


Sub AddMoney()
    Dim i As Long, lr As Long
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    For i = 2 To lr
        If Range("A" & i) = "Q10" Then
            Range("D" & i) = Range("D" & i) + 10
        Else: Range("D" & i) = Range("D" & i) + 20
        End If
    Next i


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

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