Turning a stupidly long formula it a graph type table

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,201
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,

I'd like a macro that can do the following,
in cell H5 I will put a formula, the formulas will all be the same but will vary in size, you will see what i mean in a moment,
I want to take the dat in these formulas and turn them into grath type tables
with headers Low High Answers in cell B1,C1,D1

so this is an example if the formulas,
"=IF(AND(Q6>=21,Q6<=25),1.04,IF(AND(Q6>=26,Q6<=30),1,IF(AND(Q6>=31,Q6<=35),0.96,IF(AND(Q6>=36,Q6<=40),0.91,IF(AND(Q6>=41,Q6<=45),0.87,IF(AND(Q6>=46,Q6<=50),0.82,IF(AND(Q6>=51,Q6<=55),0.76,IF(AND(Q6>=56,Q6<=60),0.71,IF(AND(Q6>=61,Q6<=70),0.58,IF(AND(Q6>=71,Q6<=80),0.41))))))))))"

So heres what I want the macro to do,
go along the formula and find the first ">=" and take the number value after that (so the value beween that and "," and place it in column B (B2)
then carry on along the formula and find "<=" take the number value after that (so the value beween that and ")" and place it in column C (C2)
then find ), and take that value and put it in column D (D2) and carry on until all the ands are in column B,C,D build out like a table

a small example of what i want is:

LowHighAnswers
21251.04
26301
31350.96
etc.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Yes, when you have a formula like that you shoyuld be using a LOOKUP table.

If the formulas "will all be the same" as the example you gave above, just create a table of the values.
If there are extra conditions in the formula just extend the table.

It's impossible to answer your query perfectly without knowing what the other formulas are. You've stated there are different formulas "will vary in size"), so presumably some formulas have extra conditions that don't appear in the example you gave. If that's the case just place the LOOKUP() within an IF() to retrieve the value you want
 
Upvote 0
Solution

Forum statistics

Threads
1,216,500
Messages
6,131,015
Members
449,615
Latest member
Nic0la

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