Add this formula in VBA

suyogpat

New Member
Joined
Jun 29, 2017
Messages
28
Hello All,

It might be a stupid question, I have below formula which I want to add in my VBA macro is not accepting the formula. What I need is macro to calculate this formula.

my excel formula is - =IF(SUMPRODUCT(--(D$3:D$7<>""),--ISNUMBER(SEARCH(D$3:D$7,A4))),"exclude","")

Anybody can help me to write this formula in VBA?I tried the recording function but problem is, its possible that I have to change the range every week in this formula. so recoding formula option wont work here. if anyone can solve, this will be a big help for me..

Thanks in advance for your help and time.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Re: How to add this formula in VBA ?? Please help

Have you thought of giving the range a dynamic name which will update automatically. If you need help with dynamic ranges, the internet is your friend.
 
Upvote 0
Re: How to add this formula in VBA ?? Please help

Hi,

Thank you for your reply. I am quite new to VBA.. I search on internet but could not find a relative context.. Can you help me with this ?

Thanks in advance for your help and time..
 
Upvote 0
Re: How to add this formula in VBA ?? Please help

Hi ,

Use this line of code to return the result of the posted formula :
Code:
formularesult = Application.Evaluate("=IF(SUMPRODUCT(--(D$3:D$7<>""""),--ISNUMBER(SEARCH(D$3:D$7,A4))),""exclude"","""")")

The VBA variable formularesult will contain either a blank or the text string exclude.
 
Upvote 0
Re: How to add this formula in VBA ?? Please help

Hi NarayanK991 ..
Works like a charm. This is what I was looking for. With few modifications in above code my macro is now completed. Thanks a lot for your help. Appreciate a lot.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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