Get last but one non blank cell

Kulsumbi

New Member
Joined
Oct 4, 2020
Messages
8
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello

I want to pull last but one non blank blan k cell

Example:

À B C D
1 2 3
5 6 7 8

I need to pull 2 and 7 that is last but one non blank cell.

Please assist
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Welcome to the MrExcel board!

Could you use something like this?

20 10 04.xlsm
ABCDEFGH
11232
256787
32N/A
425959
@nd Last
Cell Formulas
RangeFormula
H1:H4H1=IFERROR(INDEX(A1:F1,AGGREGATE(14,6,(COLUMN(A1:F1)-COLUMN(A1)+1)/(A1:F1<>""),2)),"N/A")
 
Upvote 0
Welcome to the MrExcel board!

Could you use something like this?

20 10 04.xlsm
ABCDEFGH
11232
256787
32N/A
425959
@nd Last
Cell Formulas
RangeFormula
H1:H4H1=IFERROR(INDEX(A1:F1,AGGREGATE(14,6,(COLUMN(A1:F1)-COLUMN(A1)+1)/(A1:F1<>""),2)),"N/A")


It works fine ..!! Thanks

If you don't mind.. can you just elaborate the formula, how it works ?
 
Upvote 0
can you just elaborate the formula, how it works
Take row 4

=IFERROR(INDEX(A4:F4,AGGREGATE(14,6,(COLUMN(A4:F4)-COLUMN(A4)+1)/(A4:F4<>""),2)),"N/A")
Blue part makes an array of column numbers {1,2,3,4,5,6}
Red part makes an array of True/False values {T,T,F,T,F,T}

=IFERROR(INDEX(A4:F4,AGGREGATE(14,6,({1,2,3,4,5,6})/({T,T,F,T,F,T}),2)),"N/A")

When doing the arithmetic of blue divided by red, T = 1 and F = 0 so the results array is
{1,2,#DIV/0!,4,#DIV/0!,6}

AGGREGATE(14,6,.....,2) says to take the second highest value ignoring errors = 4

INDEX then retrieves the value from the 4th cell in A4:F4. This is 9 from D4.
 
Upvote 0
Take row 4

=IFERROR(INDEX(A4:F4,AGGREGATE(14,6,(COLUMN(A4:F4)-COLUMN(A4)+1)/(A4:F4<>""),2)),"N/A")
Blue part makes an array of column numbers {1,2,3,4,5,6}
Red part makes an array of True/False values {T,T,F,T,F,T}

=IFERROR(INDEX(A4:F4,AGGREGATE(14,6,({1,2,3,4,5,6})/({T,T,F,T,F,T}),2)),"N/A")

When doing the arithmetic of blue divided by red, T = 1 and F = 0 so the results array is
{1,2,#DIV/0!,4,#DIV/0!,6}

AGGREGATE(14,6,.....,2) says to take the second highest value ignoring errors = 4

INDEX then retrieves the value from the 4th cell in A4:F4. This is 9 from D4.
Thanks❤️
 
Upvote 0

Forum statistics

Threads
1,215,772
Messages
6,126,814
Members
449,339
Latest member
Cap N

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