# Last non-empty cell in a row function

#### geversud

##### Board Regular
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.

### Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

#### pgc01

##### MrExcel MVP
Hi geversud

EDIT: My formulas imploded after barry posted his.

PGC

#### barry houdini

##### MrExcel MVP
For text or numeric....

=LOOKUP(2,1/(B1:IV1<>""),B1:IV1)

#### geversud

##### Board Regular
thank you kindly just what I needed

#### Jonmo1

##### MrExcel MVP

Ok, I've used this formula before that Barry Houdini came up with here. But what I need to do now is modify the range it looks in to skip collumns.

Say range is a1:f1
I want it only to look in collumns A C and D.

Example data

Fail | Date | Fail | Date | Pass | Date

I need to return the the Pass/Fail REsult furthest to the right.

Can anyone help?

#### barry houdini

##### MrExcel MVP
What values are in pass/fail?

Assuming they are relatively low numbers and that the dates are relatively high numbers, i.e. if they are recent dates above 10000, then perhaps

=LOOKUP(2,1/((A1:F1<10000)*(A1:F1<>"")),A1:F1)

#### Domenic

##### MrExcel MVP

Maybe...

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

Hope this helps!

#### barry houdini

##### MrExcel MVP
Domenic,

Yes, I think you've read that right - I was assuming some sort of percentage in the pass/fail cells not literally "pass"/"fail". Of course I hope the date cells don't literally contain "date"

#### Jonmo1

##### MrExcel MVP
Right, sorry wasn't more clear.

Pass / Fail is litteraly the words Pass or Fail
And dates are dates 10/20/2006. 10/26/2006 etc..

Thanks for the response, I'll give it a try and let you know how it works.

#### Domenic

##### MrExcel MVP
Domenic,

Yes, I think you've read that right - I was assuming some sort of percentage in the pass/fail cells not literally "pass"/"fail". Of course I hope the date cells don't literally contain "date"

After seeing your solution, I thought that maybe I had read it wrong. But I let my solution stand, figuring one of us had to be right.

Replies
2
Views
40
Replies
3
Views
337
Replies
6
Views
129
Replies
4
Views
152
Replies
2
Views
59

1,136,366
Messages
5,675,351
Members
419,563
Latest member
blairtab

### 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?

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