Finding Last "P"

Bundy

New Member
How can you find the last "P" on a line, without an Array formula or Code? (Excel 2000)
JA Regional Rosters work in progress.xls
ABCDEFGHIJKLMNOPQRSTUVWXY
1NamesHours8:30AM8:45AM9:00AM9:15AM9:30AM9:45AM10:00AM10:15AM10:30AM10:45AM11:00AM11:15AM11:30AM11:45AM12:00PM12:15PM12:30PM12:45PM1:00PM1:15PM1:30PM1:45PM2:00PM
2Tom900-530PPPPPLLPPB1PPCCPPPPCCC
3****0pppppLLLcccB1cc
4Harry900-500pppB1LLLcc
5Fred900-500
WEEK 1

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a \$25,000 loan, 5% annual interest, 60 month loan.

dave3009

Well-known Member
Try LOOKUP

=LOOKUP("p",4:4, COLUMN(4:4))

Will return the last instance of P in a given row in this case row 4

barry houdini

MrExcel MVP
What do you want to return, the time from row 1? Try this formula for row 2 copied down

=LOOKUP(2,1/(C2:Y2="P"),C\$1:Y\$1)

format as time

Bundy

New Member
What do you want to return, the time from row 1? Try this formula for row 2 copied down

=LOOKUP(2,1/(C2:Y2="P"),C\$1:Y\$1)

format as time

Thanks! I knew there was a way!

How does this work though?

LOOKUP(lookup_value,array)
or
LOOKUP(lookup_value,lookup_vector,result_vector)

2 isn't the lookup value we are after?

Last edited:

schielrn

Well-known Member
Lookup will return the last value of a match. If there is no match and the lookup value is greater than anything in the list it will move to the next closest value in the list. In this case it doesn't necessarily need to be 2, it could be Lookup(1.01,lookup_vector,result_vector) It just needs to be greater than 1 because (C2:Y2)="P" is going to return true/false which equates to a 1 (True) or 0 (False). So it would be either 1/1 or 1/0 which the latter would form a Div/0 error and the first one would result in 1. Then lookup just returns the last 1 in the range.

It could probably be explained a lot better, but hope that helps.

Bundy

New Member
Thanks All!

Replies
1
Views
221
Replies
2
Views
248
Replies
2
Views
730
Replies
6
Views
860
Replies
4
Views
306

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,163,878
Messages
5,834,205
Members
430,263
Latest member
abz54

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.

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

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