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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
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,224,613
Messages
6,179,901
Members
452,948
Latest member
Dupuhini

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