Find and replace formulas with vba

nlundbyek

New Member
Joined
Jun 12, 2018
Messages
4
I am trying to use find and replace to replace one formula with another. When I use my code with words in the string it works:

Sub new()


Cells.Replace What:="Hej", _
Replacement:="Farvel", LookAt:=xlWhole, SearchOrder:= _
xlByColumns, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False


End Sub

But when I use it with formulas in the string it won't work:

Sub new()


Cells.Replace What:="=LOPSLAG(C$4;'Kalender skjult'!$A$1:$H$5000;7;FALSK)", _
Replacement:="=HVIS($C$18>0;1;0)", LookAt:=xlWhole, SearchOrder:= _
xlByColumns, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False


End Sub

It's in Danish. Hope someone can tell me why it won't work with formulas :-)
 
OK thank you so much guys. Just figured out that with formulas in VBA it always has to be in English format and then it will automatically change then format to Danish afterwards :-)
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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