Find the cell with the last "X" in a column

ebrandt

Board Regular
Joined
Dec 13, 2010
Messages
54
What would be the VBA code to find the last "X" in a column starting at cell E4 and looking as far as E350? Assume that the X's will be continuous from E4 without leaving blanks until the end.

Is there also a formula that could do that?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Could there be other entries in these cells that are NOT "X" that we would need to ignore?
Or, will it just be "X" or blank?
 
Upvote 0
The cell will contain the following formula =IF(LEN(C5)>0,"X","")

so either an X or a blank produced by ""
 
Upvote 0
So, does:
cell E4 look at cell C4,
cell E5 look at cell C5,
cell E6 look at cell C6,
etc?

If that is the case, can't we simply look in column C to see where the last entry occurs, i.e.
Code:
Dim lastRow as Long
lastRow = Cells(Rows.Count,"C").End(xlUp).Row
 
Upvote 0
This formula will do it:
=LOOKUP(2,1/(E4:E350="X"),ROW(E4:E350))
 
Upvote 0
I appreciate the help.................

We can look at column C instead, but I only want to go between cells C4 and C350 and there will be either text or a formula in cell C4:350 as well. (this is the formula: ='Spec Section Transfer'!C3)

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
See Scott's reply. That should do what you want.
 
Upvote 0

Forum statistics

Threads
1,217,346
Messages
6,136,031
Members
449,979
Latest member
trinitybg10

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