Convert incell formula to VBA code

spydey

Active Member
Joined
Sep 19, 2017
Messages
314
Office Version
  1. 2013
Platform
  1. Windows
So I have a pretty complex formula that I am using in some workbooks.

I would like to convert them to VBA, but it is way over the 255 character limit that .Formula allows.

I know of and have used the replace option before, where, for example, you have a formula: =If(AAA,bbb,CCC)

You replace "AAA" with what you need that section to be, then again with "bbb", then again with "CCC", etc.

However, due to the length of the formula, this would be extremely tedious to do many iterations of replace.

I am curious, is there a better way to do it? Perhaps write the actual formula in VBA native code? I find that might be difficult given my limited abilities.

Any insight is very helpful and appreciated!

Thanks.

-Spydey
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I would like to convert them to VBA, but it is way over the 255 character limit that .Formula allows.

Hi Spydey

That limit is not for the .Formula, it's for the .FormulaArray.

This means you don't have to worry about the length of your formula
 
Upvote 0
Hi Spydey

That limit is not for the .Formula, it's for the .FormulaArray.

This means you don't have to worry about the length of your formula

That is fantastic!! I wasn't aware .... although, now that I think of it, my formulas are entered using CSE, so they are array formulas. So I would be limited to the 255 character limit, wouldn't I?

If so, are there any workarounds?

Thanks @pgc01 for your input. I appreciate it!

-Spydey
 
Upvote 0
Yes, the cse formulas will have that limit.

In that case the workaround is the one with the replace that you posted.
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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