VBA Error 1004 when trying to put equals sign in cell value

YungRichSavage

New Member
Joined
Oct 20, 2017
Messages
5
Im trying to do something like this

"om" is the if formula but in my language

Range("f3").Value = "=OM(+'1'!H3=0;"";+'1'!H3)"

and for some reason i get the 1004 application or object defined error

when i do this the first line of code works but the same error appers on the next line, why?

Range("f3").Value = "OM(+'1'!H3=0;"";+'1'!H3)"
Range("f3").Value = "=" & Range("f3").Value
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Change this

Code:
Range("f3").Value = "=" & Range("f3").Value

To

Code:
Range("f3").Value = Range("f3").Formula
 
Upvote 0
Hi. When you say this works:

Range("f3").Value = "OM(+'1'!H3=0;"";+'1'!H3)"

Take a look at it on the spreadsheet. You will notice that the pair of inverted commas, "", is no longer "" but ". For that to work correctly in a string you need to use """" not "".
 
Upvote 0
You can also use:


Code:
Range("f3").Value = "=OM(+'1'!H3=0;" & Chr(34) & Chr(34) & ";+'1'!H3)"

Regards,

CJ
 
Upvote 0
Still doesn't work,
Code:
Range("f3").Value = "OM(+'1'!H3=0;"""";+'1'!H3)"
        Range("f3").Value = Range("f3").Formula

still just appears as a string, no equals sign or anything

I have to fill about 4000 cells with formulas so really want to figure this out :)
 
Upvote 0
CFFiQXL.png
SoiqN4q.png


Both of theese genreate the error

VsFgo0t.png


and this adds ' instead of =
 
Upvote 0
Try using commas instead of semi colons. I cant test as i dont use a foreign language version.

Code:
Range("f3").Formula = "=OM(+'1'!H3=0,"""",+'1'!H3)"

Other than that record putting the formula in the cell and look what the recorder produces.
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,184
Members
448,949
Latest member
keycalinc

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