I've got an entry in one (actually several) of my cells on a spreadsheet that is a bit unwieldy. It is actually made up of several similar strings of nested functions that are just begging to be put into a macro, but I'm not sure where to start. Here is the function I am trying to simplify.
={SUM((INDIRECT(A4&INDEX(SheetRanges,MATCH(A4,Worksheet_Names,0),MATCH("Unit",RangeHeadings,0)))=B4)*(INDIRECT(A4&INDEX(SheetRanges,MATCH(A4,Worksheet_Names,0),MATCH("Type",RangeHeadings,0)))=C4)*(INDIRECT(A4&INDEX(SheetRanges,MATCH(A4,Worksheet_Names,0),MATCH("Inc",RangeHeadings,0))) = "x"))}
Note that "SheetRanges" "Worksheet_Names" and "RangeHeadings" are all defined ranges via the "Name Manager". As you can see this is made up of three nested lookups that are identical except for the second match target. I was hoping to be able to take this portion:
INDIRECT(A4&INDEX(SheetRanges,MATCH(A4,Worksheet_Names,0),MATCH("Unit",RangeHeadings,0)))
And convert it into a macro function that takes A4 and "Unit" as inputs and returns a Range.
The problem is I'm not sure where to start. Any help would be appreciated.
={SUM((INDIRECT(A4&INDEX(SheetRanges,MATCH(A4,Worksheet_Names,0),MATCH("Unit",RangeHeadings,0)))=B4)*(INDIRECT(A4&INDEX(SheetRanges,MATCH(A4,Worksheet_Names,0),MATCH("Type",RangeHeadings,0)))=C4)*(INDIRECT(A4&INDEX(SheetRanges,MATCH(A4,Worksheet_Names,0),MATCH("Inc",RangeHeadings,0))) = "x"))}
Note that "SheetRanges" "Worksheet_Names" and "RangeHeadings" are all defined ranges via the "Name Manager". As you can see this is made up of three nested lookups that are identical except for the second match target. I was hoping to be able to take this portion:
INDIRECT(A4&INDEX(SheetRanges,MATCH(A4,Worksheet_Names,0),MATCH("Unit",RangeHeadings,0)))
And convert it into a macro function that takes A4 and "Unit" as inputs and returns a Range.
The problem is I'm not sure where to start. Any help would be appreciated.