VBA code to find/replace

mfh1287

New Member
Joined
Mar 13, 2013
Messages
28
I'm trying to figure out a vba code to take the contents of cell "B1" and replace it in a formula in cell "C1" and then loop to the end of the data set. Can someone help me out with this? Thanks
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I'm trying to figure out a vba code to take the contents of cell "B1" and replace it in a formula in cell "C1" and then loop to the end of the data set. Can someone help me out with this? Thanks
Here,try this code on a SAMPLE data:
Code:
Sub Find_Replace()
For Each Cell In Range("B1:B" & Cells(Rows.Count, 2).End(xlUp).Row)
    Cell.Value = Cell.Offset(0, 1).Formula
Next
End Sub
ZAX
 
Upvote 0
I don't know what do you want??
Be more specific Plz :)
ZAX

I have a formula in cell c1 that that has a part in quotes - I'm looking for a vba code that will take the contents in B1 and put it in the formula between the quotes. I can do find and replace one by one, but I have to do it over 50 times, so I'm trying to figure out a macro that would take B1 and put it in the formula in C1, then B2 into C2 and so on until the end of the data set.

Hopefully that makes more sense.

Thanks again
 
Upvote 0
I have a formula in cell c1 that that has a part in quotes - I'm looking for a vba code that will take the contents in B1 and put it in the formula between the quotes. I can do find and replace one by one, but I have to do it over 50 times, so I'm trying to figure out a macro that would take B1 and put it in the formula in C1, then B2 into C2 and so on until the end of the data set.

Hopefully that makes more sense.

Thanks again
Ha,Now I understand,here's a code that will help you:
Code:
Sub Find_Replace()
For Each Cell In Range("C1:C" & Cells(Rows.Count, 3).End(xlUp).Row)
    Cell.Formula = Left(Cell.Formula, InStr(1, Cell.Formula, """")) & Cell.Offset(0, -1).Value & Right(Cell.Formula, Len(Cell.Formula) - InStr(1, Cell.Formula, """"))
Next
End Sub
ZAX :cool:
 
Upvote 0

Forum statistics

Threads
1,221,553
Messages
6,160,467
Members
451,649
Latest member
fahad_ibnfurjan

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