VBA to update cell value based on another cell

olympiac

Board Regular
Joined
Sep 26, 2010
Messages
158
I need to update the values in column A based on the value in column B.
Here is the code:

If Range("A2").Value = "refrin" Then
Range("B2").Value = "RefrinDHP"

Else

End If
If Range("A3").Value = "refrin" Then
Range("B3").Value = "RefrinDHP"
etc......

I need to continue it until the end of the column.
Do I need to use a loop? Can you help please?
 
Now if I wanted it all to be the same, but instead of a formula, delete the row that matches Range("d" & i).Value = "Calendar"? Here's what i've tried before. Can I do multiple actions in an if statement?

Code:
If Range("d" & i) = "calendar" Then    
    Range(i).Select
    Selection.Delete Shift:=xlUp
    End If
    Next i
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
What code do I need below along with For I = LastRow to 2 Step -1?
Code:
If Range("d" & i) = "calendar" Then        
Range(i).Select    
Selection.Delete Shift:=xlUp    
End If    
Next i
 
Upvote 0

Forum statistics

Threads
1,215,148
Messages
6,123,301
Members
449,095
Latest member
Chestertim

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