Combining 2 or more Formulae in VBA

shoogerjar

New Member
Joined
Jul 30, 2014
Messages
9
Hi,

I need help in translating the below formula into vba code. Thank you.

=IF(ISERROR(FIND("LK",A47)),"false","true")
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try, for example
Code:
Range("A1").Formula = "=IF(ISERROR(FIND(""LK"",A47)),""false"",""true"")"
 
Upvote 0
Assuming this goes to Cell B47 in Sheet1 then

Code:
sheets("[COLOR=#0000cd]Sheet1[/COLOR]").Range("[COLOR=#0000cd]B47[/COLOR]").formula="=IF(ISERROR(FIND(""LK"",A47)),""FALSE"",""TRUE"")"

Change Accordingly.
 
Upvote 0
Hi,

I tried to incorporate 2 searches into one formula but ended up with the "application defined object defined error". The code is as follows:

Code:
[COLOR=#333333]Range("A1")[/COLOR].Formula = "=OR(IF(ISERROR(FIND(""LK"",U1)),FALSE,TRUE),IF(ISERROR(FIND(""SK"",U1)),FALSE,TRUE)"

I am trying to identify if the cell in U1 contains either LK or SK. Appreciate if anyone can help with this. Thank you.
 
Upvote 0
Maybe this instead
Code:
Range("A1").Formula = "=IF(OR(U1=""LK"",U1=""SK""),TRUE,FALSE)"
 
Upvote 0
Hi Michael,

Thanks for your reply but I am actually looking at a formula to check if the cell contains either LK or SK (For e.g. BULK or DUSK) hence your formula will not apply for this case.
 
Upvote 0
Sorry, didn't realise that.
Try
Code:
Range("A1").Formula ="=IF(OR(ISERROR(FIND(""LK"",U1)),ISERROR(FIND(""SK"",U1))),FALSE,TRUE)"
But do you understand that this will always return FALSE, unless there is something like "SKULK" in U1
 
Upvote 0
Hi Michael, yes I tried your formula and it will always return FALSE. Hence I used

Code:
Range("A1").Formula = "=OR(IF(ISERROR(FIND(""LK"",U1)),FALSE,TRUE),IF(ISERROR(FIND(""SK"",U1)),FALSE,TRUE)"

with the OR outside instead of the IF. It works when I enter it in a normal excel cell but gives me error when I try to run it in vba.
 
Upvote 0
You were missing a bracket
Code:
Range("A1").Formula = "=OR(IF(ISERROR(FIND(""LK"",U1)),FALSE,TRUE),IF(ISERROR(FIND(""SK"",U1)),FALSE,TRUE))"
]
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,693
Members
449,048
Latest member
81jamesacct

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