Replace the "=" in a cell formula using VBA

QuantBurner

New Member
Joined
Jan 29, 2011
Messages
42
Hiya,
so I have some cell formulas that refer to a sheet where I delete everything and then raplace the data using VBA code. of course, the delete causes #REF! errors. I thought I could use:
sheet(x).usedRange.Replace What:="=", Replacement:="'@#", LookAt:=xlPart
to replace the equals sign before I delete stuff and then use another replace:
sheet(x).usedRange.Replace What:="@#", Replacement:="'=", LookAt:=xlPart
afterwards.
Excel is too smart and does nothing. If I use '@# as the replace it works but, then the replace '@# with = doesn't as the replace doen't seem to recognize the '
Any ideas as to how to get the replace to work?

I just realized that instead of deleteing, if I use clearcontents I'd be fine. But, I'd still like a workaround for the replace.

Cheers
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
What about using...

sheet(x).usedRange.Replace What:="=", Replacement:="zz", LookAt:=xlPart

and

sheet(x).usedRange.Replace What:="zz", Replacement:="=", LookAt:=xlPart
 
Upvote 0
Not sure, but maybe Missing " ' " (in red) below...

sheet(x).usedRange.Replace What:="'@#", Replacement:="'=", LookAt:=xlPart
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

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