Is it possible to make TYPE and CELL functions to work on a selected range?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
528
Office Version
  1. 365
Platform
  1. Windows
Hello,

Just wondering if it is possible to make the TYPE and CELL functions work on a selected range, such that the output would be a spill corresponding to each of the cells (and not the entire selection) within the selected range. Here is an example of what I mean exactly:

Blank power workbook1
ABCDEFGHIJKLMN
14475014475044750
2ant53g6TRUE#DIV/0!t?
37.9#N/A#SPILL!FALSEh 89book8-Jul8iTRUE
4
5individual cells dragged:2221121416122
611616422121124
7
8selected range:64
9
10
11individual cells dragged:lllvvlvvvbll
12vvvvllvlvvlv
13
14selected range:l
15
16
Sheet1
Cell Formulas
RangeFormula
K1K1=TEXT(J3,10)
J1J1=VALUE(J3)
J2J2=1/0
C3C3=NA()
D3D3={1,2,3}
G3G3=IF(C1>2,1,"")
B5:M6B5=TYPE(B2)
B8B8=TYPE(B2:M3)
B11:M12B11=CELL("type",B2)
B14B14=CELL("type",B2:M3)



Here, B8 returns the type of the entire selection (which is of course its expected job), but would it be possible to make the formula in B8 to spill the same results as in B5:M6? And similarly, would it be possible to make the formula in B14 to spill the same results as in B11:M12?

Thanks for any input 🤗
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Not directly as far as I know that TYPE and CELL functions cannot spill.

However, perhaps using the MAKEARRAY function as shown below (being not sure about the performance):

Blank power workbook1
ABCDEFGHIJKLM
14475014475044750
2ant53g6TRUE#DIV/0!t?
37.9#N/A#SPILL!FALSEh 89book447508iTRUE
4
5individual cells dragged:2221121416122
611616422121124
7
8selected range:2221121416122
911616422121124
10
11individual cells dragged:lllvvlvvvbll
12vvvvllvlvvlv
13
14selected range:lllvvlvvvbll
15vvvvllvlvvlv
Sheet1
Cell Formulas
RangeFormula
K1K1=TEXT(J3,10)
J1J1=VALUE(J3)
J2J2=1/0
C3C3=NA()
D3D3={1,2,3}
G3G3=IF(C1>2,1,"")
B5:M6B5=TYPE(B2)
B8:M9B8=MAKEARRAY(ROWS(B2:M3),COLUMNS(B2:M3),LAMBDA(r,c,TYPE(INDEX(B2:M3,r,c))))
B11:M12B11=CELL("type",B2)
B14:M15B14=MAKEARRAY(ROWS(B2:M3),COLUMNS(B2:M3),LAMBDA(r,c,CELL("type", INDEX(B2:M3,r,c))))
Dynamic array formulas.
 
Upvote 0
Thank you so much! 🤗 This is exactly what I was looking for and thinking about.

(Before your response, I was thinking more about how to generate a "sequence of functions" similar to how SEQUENCE makes a sequence of numbers, and your solution is a perfect demonstration of that.)
 
Upvote 0
One question: when I use your formula in LET, like this:

=LET(range,B2:M3,MAKEARRAY(ROWS(range),COLUMNS(range),LAMBDA(r,c,CELL("type", INDEX(range,r,c)))))

then I get a spill of errors.

How can I correct this scenario? Thanks much! 🤗

Also wondering why the same spill of errors doesn't happen with TYPE, when using LET? (It only happens with CELL)
 
Upvote 0
You are right.

Honestly, I will likely continue thinking about this tomorrow with fresh mind but I really don't have any logical explanation for this. It should be something "special" about the CELL function. :unsure:
 
Upvote 0
Sure, thanks much. Hope you can figure out a solution for the error spill.
 
Upvote 0
I have been looking a lot into this, and so far my understanding is that the reason for the error for CELL in my post #5 is that the LET that I defined is outside of the MAKEARRAY's LAMBDA, so this internal LAMBDA does not recognize the external LET's parameters and definitions. I tested this by putting a LET inside the LAMBDA and it worked fine:

Excel Formula:
=MAKEARRAY(ROWS(B2:M3),COLUMNS(B2:M3),LAMBDA(r,c,LET(range,B2:M3,CELL("type", INDEX(range,r,c)))))

which is of course not helpful, but shows what is happening.

And the reason TYPE worked with the outside LET is that TYPE works with ranges anyways, so it never even saw the variable from the outside LET even though that variable was defined.

So now the big question is how to supply a variable from the outside LET of my post 5 into the internal LAMBDA of MAKEARRAY :unsure: because my goal is to put the MAKEARRAY inside a LET which will itself be inside the main LAMBDA that I'm coding for.
 
Last edited:
Upvote 0
The Makearray function can see the variables in the original Let function, the problem is more likely to be that the Range once passed to Makearray becomes an array.
 
Upvote 0
I see, thank you.

I attempted to "reconstruct" the "range" through INDIRECT as follows, based on one of the solutions from my other thread:


Excel Formula:
=LET(range,B2:M3,MAKEARRAY(ROWS(range),COLUMNS(range),LAMBDA(r,c,CELL("type", INDEX(INDIRECT(TAKE(ADDRESS(ROW(range),COLUMN(range),4),1,1)&":"&TAKE(ADDRESS(ROW(range),COLUMN(range),4),-1,-1)),r,c)))))

I assumed that an INDIRECT-generated range should still be a range rather than an array, though not sure if this a correct assumption?

Unfortunately, the Evaluate Formula window turns blank exactly at the time that it tries to evaluate the INDIRECT portion 😭😅 so I cannot see what happens at that stage.

Even with INDIRECT, I'm still getting errors, though now different: the first error is #VALUE followed by #REF errors 🤔 Any idea why? (I did it in two ways with external and internal ranges relative to the LAMBDA)


Blank power workbook1
ABCDEFGHIJKLMN
1
2ant53g6TRUE#DIV/0!t?
37.9#N/A#SPILL!FALSEh 89book447508iTRUE
4
5individual cells dragged:2221121416122
611616422121124
7
8selected range:2221121416122
911616422121124
10
11individual cells dragged:lllvvlvvvbll
12vvvvllvlvvlv
13
14selected range:lllvvlvvvbll
15vvvvllvlvvlv
16
17B14 formula with LET:#VALUE!#VALUE!#VALUE!#VALUE!#VALUE!#VALUE!#VALUE!#VALUE!#DIV/0!#VALUE!#VALUE!#VALUE!
18#VALUE!#N/A#SPILL!#VALUE!#VALUE!#VALUE!#VALUE!#VALUE!#VALUE!#VALUE!#VALUE!#VALUE!
19
20
21INDIRECT with external range:#VALUE!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!
22#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!
23
24
25INDIRECT with internal range:#VALUE!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!
26#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!#REF!
27
Sheet1
Cell Formulas
RangeFormula
J2J2=1/0
C3C3=NA()
D3D3={1,2,3}
G3G3=IF(C1>2,1,"")
B5:M6B5=TYPE(B2)
B8:M9B8=MAKEARRAY(ROWS(B2:M3),COLUMNS(B2:M3),LAMBDA(r,c,TYPE(INDEX(B2:M3,r,c))))
B11:M12B11=CELL("type",B2)
B14:M15B14=MAKEARRAY(ROWS(B2:M3),COLUMNS(B2:M3),LAMBDA(r,c,CELL("type", INDEX(B2:M3,r,c))))
B17:M18B17=LET(range,B2:M3,MAKEARRAY(ROWS(range),COLUMNS(range),LAMBDA(r,c,CELL("type", INDEX(range,r,c)))))
B21:M22B21=LET(range,B2:M3,MAKEARRAY(ROWS(range),COLUMNS(range),LAMBDA(r,c,CELL("type", INDEX(INDIRECT(TAKE(ADDRESS(ROW(range),COLUMN(range),4),1,1)&":"&TAKE(ADDRESS(ROW(range),COLUMN(range),4),-1,-1)),r,c)))))
B25:M26B25=LET(range,B2:M3,MAKEARRAY(ROWS(range),COLUMNS(range),LAMBDA(r,c,LET(irange,B2:M3,x,INDIRECT(TAKE(ADDRESS(ROW(irange),COLUMN(irange),4),1,1)&":"&TAKE(ADDRESS(ROW(range),COLUMN(irange),4),-1,-1)),CELL("type", INDEX(x,r,c))))))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,011
Members
449,204
Latest member
tungnmqn90

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