Last non-empty cell in a row function

geversud

Board Regular
Joined
Jul 17, 2002
Messages
181
What is the best way to return the contents of the last empty cell in a row in a worksheet function?

e.g. If I have a function in Column A, then I want the function in Column A to identify the last column that has data in it and return its contents. It needs to be dynamic because columns are constantly being added.
 
that was close domenic,

The problem is there are other collumns in the range that have other text. That formula finds the cell with any text furthest to the right. What I really need is to define my own array as K:K + P:P + U:U + Z:Z and make the formula refernce that array.

I've gone to insert - name - define and defined a range as described above and named it "myrange"

How can I get the formula to reference that range named "myrange"?
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try...

=LOOKUP(REPT("z",255),IF(MOD(COLUMN(K2:Z2)-COLUMN(K2),5)=0,K2:Z2))

...confirmed with CONTROL+SHIFT+ENTER, not just ENTER. Adjust the range accordingly.

Hope this helps!
 
Upvote 0
I appreciate you trying, but it's still returning ANY text furthest to the right in the range. Basically, I have 8 sets of collumns, each with a Test result, test date, date result recieved ,comments.

Test1 Result | Test1 Date | Test1 Results Date | Test1 Comments | Test2 Result | Test2 Date | Test2 REsults Date | Test 2 Comments etc...repeated for 8 tests.

So the last formula is getting close, but it's returning Comments, instead of Test Results.

I need the test result furthest to the right.
 
Upvote 0
Excellent, it works now. I just rearranged my source data so the copllumn with the Test results is to the Right of the Collumn with the comments.

Thank you for your help.
 
Upvote 0
I see from your last example that every 4 cells (not 5 as in your previous example) contains a test result. In this case, you'll need to change the MOD divisor from 5 to 4.
 
Upvote 0
Actually, I got it going great with your first formula suggestion.

=LOOKUP(REPT("z",255),A1:F1)

I just had to rearrange my source data so that the Test Results were to the right of the comments.

Thanks
 
Upvote 0
Oh I see. Of course, if the test result is not available but a comment exists, the formula will return the comment. But I assume the only time a test will have a comment is when a result exists, so I guess this is not an issue...
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,539
Members
449,038
Latest member
Guest1337

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