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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
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,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