Finding Last "P"

Bundy

New Member
Joined
Jul 18, 2007
Messages
49
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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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
 
Upvote 0
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
 
Upvote 0
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:
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,257
Members
448,880
Latest member
aveternik

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