Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default Next to last non-empty cell in row

Is there a way to select the next to last non-empty cell in a row?
Thank you.
--
Cong Nguyen

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 78
Default Next to last non-empty cell in row

Cong,
Try Ctrl+right arrow, let go of the Ctrl key and press left arrow.

Hope this helps.
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default Next to last non-empty cell in row

Ellen,
Thanks for the tip, but I need a formula.

--
Cong Nguyen



"Cong Nguyen" wrote:

Is there a way to select the next to last non-empty cell in a row?
Thank you.
--
Cong Nguyen

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Next to last non-empty cell in row

Lets say the last filled cell in row #9 is K9
and that J9 contains 5. Then

=WhereIsIt(9) will display $J$9 - the location
of the next to the last filled cell in row 9

=WhatsInIt(9) will display 5, the content of that cell.

Here is the code:

Function WhereIsIt(n As Long) As String
m = Cells(n, Columns.Count).End(xlToLeft).Column
WhereIsIt = Cells(n, m - 1).Address
End Function

Function WhatsInIt(n As Long) As Variant
m = Cells(n, Columns.Count).End(xlToLeft).Column
WhatsInIt = Cells(n, m - 1).Value
End Function
--
Gary''s Student - gsnu200749


"Cong Nguyen" wrote:

Is there a way to select the next to last non-empty cell in a row?
Thank you.
--
Cong Nguyen

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 150
Default Next to last non-empty cell in row

If the data contains numerical values...

=LOOKUP(9.99999999999999E+307,A2:INDEX(A2:A100,MAT CH(9.99999999999999E+30
7,A2:A100)-1))

If the data contains text values...

=LOOKUP(REPT("z",255),A2:INDEX(A2:A100,MATCH(REPT( "z",255),A2:A100)-1))

Adjust the ranges accordingly.

Hope this helps!

In article ,
Cong Nguyen wrote:

Is there a way to select the next to last non-empty cell in a row?
Thank you.



  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 150
Default Next to last non-empty cell in row

Does the data contain formula blanks ("") ? If so, try the following
formula instead...

=INDEX(A2:A100,LARGE(IF(A2:A100<"",ROW(A2:A100)-ROW(A2)+1),2))

Note that the formula needs to be confirmed with CONTROL+SHIFT+ENTER,
not just ENTER.

Hope this helps!

In article ,
Cong Nguyen wrote:

Domenic,
The formula for text gives the last non-empty data, not the previous.
Thank you
--
Cong Nguyen

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
When is a cell empty and how do I empty it. C Brandt Excel Discussion (Misc queries) 5 August 13th 07 05:37 PM
find first empty cell in column and start transpose next row in that cell ali Excel Discussion (Misc queries) 6 July 21st 07 11:55 PM
format a cell with a formula so an empty reference cell shows blan M2 Excel Discussion (Misc queries) 3 November 7th 06 10:42 PM
Leaving an empty cell empty GRL Excel Discussion (Misc queries) 4 April 22nd 06 05:47 PM
why a reference to an empty cell is not considered empty Nicoscot Excel Discussion (Misc queries) 10 March 10th 06 05:36 AM


All times are GMT +1. The time now is 06:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"