PC Review


Reply
Thread Tools Rate Thread

Another 'Last cell in column' question

 
 
Compass Rose
Guest
Posts: n/a
 
      3rd Jul 2008
In Excel 2003

I've searched through the archives, but couldn't find a solution to my
particular problem.

In column B, I have filled from row 2 to row 1250 with:

=IF(blah blah,"",blah blah)

To find the last row in the column that isn't blank, I tried:

lr = Cells(Rows.Count, "B").End(xlUp).Row

which returns the value of 1250.

What I need is the last row in column B where the IF condition is FALSE, and
there is text in that cell.

TIA
David
 
Reply With Quote
 
 
 
 
Geoff K
Guest
Posts: n/a
 
      3rd Jul 2008
try something like this and substituting your real column and False result

Option Explicit

Sub testit()
Dim foundit As Range
Set foundit = Columns("E").Find(<<False result in quotes>>, , xlValues,
xlWhole, xlByRows, xlPrevious)
MsgBox foundit.Row
End Sub

hth

Geoff K

"Compass Rose" wrote:

> In Excel 2003
>
> I've searched through the archives, but couldn't find a solution to my
> particular problem.
>
> In column B, I have filled from row 2 to row 1250 with:
>
> =IF(blah blah,"",blah blah)
>
> To find the last row in the column that isn't blank, I tried:
>
> lr = Cells(Rows.Count, "B").End(xlUp).Row
>
> which returns the value of 1250.
>
> What I need is the last row in column B where the IF condition is FALSE, and
> there is text in that cell.
>
> TIA
> David

 
Reply With Quote
 
Compass Rose
Guest
Posts: n/a
 
      3rd Jul 2008
It won't work because the FALSE result varies - it is a cell reference to
another sheet...

David

"Geoff K" wrote:

> try something like this and substituting your real column and False result
>
> Option Explicit
>
> Sub testit()
> Dim foundit As Range
> Set foundit = Columns("E").Find(<<False result in quotes>>, , xlValues,
> xlWhole, xlByRows, xlPrevious)
> MsgBox foundit.Row
> End Sub
>
> hth
>
> Geoff K
>
> "Compass Rose" wrote:
>
> > In Excel 2003
> >
> > I've searched through the archives, but couldn't find a solution to my
> > particular problem.
> >
> > In column B, I have filled from row 2 to row 1250 with:
> >
> > =IF(blah blah,"",blah blah)
> >
> > To find the last row in the column that isn't blank, I tried:
> >
> > lr = Cells(Rows.Count, "B").End(xlUp).Row
> >
> > which returns the value of 1250.
> >
> > What I need is the last row in column B where the IF condition is FALSE, and
> > there is text in that cell.
> >
> > TIA
> > David

 
Reply With Quote
 
Geoff K
Guest
Posts: n/a
 
      3rd Jul 2008
A more complete solution should also allow for a fail to find so this is
better:
Option Explicit

Sub testit()
Dim foundit As Range
Set foundit = Columns("B").Find(<<False result in quotes>>, , xlValues,
xlWhole, xlByRows, xlPrevious)
If Not foundit Is Nothing Then
MsgBox foundit.Row
Else
MsgBox "All results = True"
End If
End Sub


"Geoff K" wrote:

> try something like this and substituting your real column and False result
>
> Option Explicit
>
> Sub testit()
> Dim foundit As Range
> Set foundit = Columns("E").Find(<<False result in quotes>>, , xlValues,
> xlWhole, xlByRows, xlPrevious)
> MsgBox foundit.Row
> End Sub
>
> hth
>
> Geoff K
>
> "Compass Rose" wrote:
>
> > In Excel 2003
> >
> > I've searched through the archives, but couldn't find a solution to my
> > particular problem.
> >
> > In column B, I have filled from row 2 to row 1250 with:
> >
> > =IF(blah blah,"",blah blah)
> >
> > To find the last row in the column that isn't blank, I tried:
> >
> > lr = Cells(Rows.Count, "B").End(xlUp).Row
> >
> > which returns the value of 1250.
> >
> > What I need is the last row in column B where the IF condition is FALSE, and
> > there is text in that cell.
> >
> > TIA
> > David

 
Reply With Quote
 
Geoff K
Guest
Posts: n/a
 
      3rd Jul 2008
Is the True result a constant then?

Geoff K

"Compass Rose" wrote:

> It won't work because the FALSE result varies - it is a cell reference to
> another sheet...
>
> David
>
> "Geoff K" wrote:
>
> > try something like this and substituting your real column and False result
> >
> > Option Explicit
> >
> > Sub testit()
> > Dim foundit As Range
> > Set foundit = Columns("E").Find(<<False result in quotes>>, , xlValues,
> > xlWhole, xlByRows, xlPrevious)
> > MsgBox foundit.Row
> > End Sub
> >
> > hth
> >
> > Geoff K
> >
> > "Compass Rose" wrote:
> >
> > > In Excel 2003
> > >
> > > I've searched through the archives, but couldn't find a solution to my
> > > particular problem.
> > >
> > > In column B, I have filled from row 2 to row 1250 with:
> > >
> > > =IF(blah blah,"",blah blah)
> > >
> > > To find the last row in the column that isn't blank, I tried:
> > >
> > > lr = Cells(Rows.Count, "B").End(xlUp).Row
> > >
> > > which returns the value of 1250.
> > >
> > > What I need is the last row in column B where the IF condition is FALSE, and
> > > there is text in that cell.
> > >
> > > TIA
> > > David

 
Reply With Quote
 
Geoff K
Guest
Posts: n/a
 
      3rd Jul 2008
If the False result is a ref to another sheeet there must be some sheet id
which can be used to differentiate from True even if it is only the word
"Sheet" ? If that is the case then change the find statement from xlWhole to
xlPart and use "Sheet".

hth

Geoff

"Geoff K" wrote:

> A more complete solution should also allow for a fail to find so this is
> better:
> Option Explicit
>
> Sub testit()
> Dim foundit As Range
> Set foundit = Columns("B").Find(<<False result in quotes>>, , xlValues,
> xlWhole, xlByRows, xlPrevious)
> If Not foundit Is Nothing Then
> MsgBox foundit.Row
> Else
> MsgBox "All results = True"
> End If
> End Sub
>
>
> "Geoff K" wrote:
>
> > try something like this and substituting your real column and False result
> >
> > Option Explicit
> >
> > Sub testit()
> > Dim foundit As Range
> > Set foundit = Columns("E").Find(<<False result in quotes>>, , xlValues,
> > xlWhole, xlByRows, xlPrevious)
> > MsgBox foundit.Row
> > End Sub
> >
> > hth
> >
> > Geoff K
> >
> > "Compass Rose" wrote:
> >
> > > In Excel 2003
> > >
> > > I've searched through the archives, but couldn't find a solution to my
> > > particular problem.
> > >
> > > In column B, I have filled from row 2 to row 1250 with:
> > >
> > > =IF(blah blah,"",blah blah)
> > >
> > > To find the last row in the column that isn't blank, I tried:
> > >
> > > lr = Cells(Rows.Count, "B").End(xlUp).Row
> > >
> > > which returns the value of 1250.
> > >
> > > What I need is the last row in column B where the IF condition is FALSE, and
> > > there is text in that cell.
> > >
> > > TIA
> > > David

 
Reply With Quote
 
Compass Rose
Guest
Posts: n/a
 
      3rd Jul 2008
The formula in B2 is:

=IF(ROWS($1:1)>COUNT(A:A),"",INDEX(Sheet1!X:X,SMALL(A:A,ROWS($1:1))+9))

The formula in B1250 is:

=IF(ROWS($1:1249)>COUNT(A:A),"",INDEX(Sheet1!X:X,SMALL(A:A,ROWS
_($1:1249))+9))

Your statement Set foundit = Columns("B").Find("Sheet1", , xlValues,
> > xlWhole, xlByRows, xlPrevious) will find row 1250 as the last row.


Currently, cells B2 to B451 have data in them because the IF is FALSE. Cells
B452 to B1249 are "" (blank) because the IF is TRUE. I want to sort the range
B2:F451 (lastrow), using column B as the key. I need to find the last row
that has data in it so that I'm not sorting B2:F1250. In a week from now, the
data in column B may go to row 520, so I'll want to sort B2:F520.

I hope this clarifies my problem.

David


"Geoff K" wrote:

> If the False result is a ref to another sheeet there must be some sheet id
> which can be used to differentiate from True even if it is only the word
> "Sheet" ? If that is the case then change the find statement from xlWhole to
> xlPart and use "Sheet".
>
> hth
>
> Geoff
>
> "Geoff K" wrote:
>
> > A more complete solution should also allow for a fail to find so this is
> > better:
> > Option Explicit
> >
> > Sub testit()
> > Dim foundit As Range
> > Set foundit = Columns("B").Find(<<False result in quotes>>, , xlValues,
> > xlWhole, xlByRows, xlPrevious)
> > If Not foundit Is Nothing Then
> > MsgBox foundit.Row
> > Else
> > MsgBox "All results = True"
> > End If
> > End Sub
> >
> >
> > "Geoff K" wrote:
> >
> > > try something like this and substituting your real column and False result
> > >
> > > Option Explicit
> > >
> > > Sub testit()
> > > Dim foundit As Range
> > > Set foundit = Columns("E").Find(<<False result in quotes>>, , xlValues,
> > > xlWhole, xlByRows, xlPrevious)
> > > MsgBox foundit.Row
> > > End Sub
> > >
> > > hth
> > >
> > > Geoff K
> > >
> > > "Compass Rose" wrote:
> > >
> > > > In Excel 2003
> > > >
> > > > I've searched through the archives, but couldn't find a solution to my
> > > > particular problem.
> > > >
> > > > In column B, I have filled from row 2 to row 1250 with:
> > > >
> > > > =IF(blah blah,"",blah blah)
> > > >
> > > > To find the last row in the column that isn't blank, I tried:
> > > >
> > > > lr = Cells(Rows.Count, "B").End(xlUp).Row
> > > >
> > > > which returns the value of 1250.
> > > >
> > > > What I need is the last row in column B where the IF condition is FALSE, and
> > > > there is text in that cell.
> > > >
> > > > TIA
> > > > David

 
Reply With Quote
 
Geoff K
Guest
Posts: n/a
 
      3rd Jul 2008
If this results in 1250 then 1250 cannot be blank
Set foundit = Columns("B").Find("*", , xlValues, xlPart, xlByRows, xlPrevious)

If this does not work then I apologise if I have created false hope.

Geoff K

"Compass Rose" wrote:

> The formula in B2 is:
>
> =IF(ROWS($1:1)>COUNT(A:A),"",INDEX(Sheet1!X:X,SMALL(A:A,ROWS($1:1))+9))
>
> The formula in B1250 is:
>
> =IF(ROWS($1:1249)>COUNT(A:A),"",INDEX(Sheet1!X:X,SMALL(A:A,ROWS
> _($1:1249))+9))
>
> Your statement Set foundit = Columns("B").Find("Sheet1", , xlValues,
> > > xlWhole, xlByRows, xlPrevious) will find row 1250 as the last row.

>
> Currently, cells B2 to B451 have data in them because the IF is FALSE. Cells
> B452 to B1249 are "" (blank) because the IF is TRUE. I want to sort the range
> B2:F451 (lastrow), using column B as the key. I need to find the last row
> that has data in it so that I'm not sorting B2:F1250. In a week from now, the
> data in column B may go to row 520, so I'll want to sort B2:F520.
>
> I hope this clarifies my problem.
>
> David
>
>
> "Geoff K" wrote:
>
> > If the False result is a ref to another sheeet there must be some sheet id
> > which can be used to differentiate from True even if it is only the word
> > "Sheet" ? If that is the case then change the find statement from xlWhole to
> > xlPart and use "Sheet".
> >
> > hth
> >
> > Geoff
> >
> > "Geoff K" wrote:
> >
> > > A more complete solution should also allow for a fail to find so this is
> > > better:
> > > Option Explicit
> > >
> > > Sub testit()
> > > Dim foundit As Range
> > > Set foundit = Columns("B").Find(<<False result in quotes>>, , xlValues,
> > > xlWhole, xlByRows, xlPrevious)
> > > If Not foundit Is Nothing Then
> > > MsgBox foundit.Row
> > > Else
> > > MsgBox "All results = True"
> > > End If
> > > End Sub
> > >
> > >
> > > "Geoff K" wrote:
> > >
> > > > try something like this and substituting your real column and False result
> > > >
> > > > Option Explicit
> > > >
> > > > Sub testit()
> > > > Dim foundit As Range
> > > > Set foundit = Columns("E").Find(<<False result in quotes>>, , xlValues,
> > > > xlWhole, xlByRows, xlPrevious)
> > > > MsgBox foundit.Row
> > > > End Sub
> > > >
> > > > hth
> > > >
> > > > Geoff K
> > > >
> > > > "Compass Rose" wrote:
> > > >
> > > > > In Excel 2003
> > > > >
> > > > > I've searched through the archives, but couldn't find a solution to my
> > > > > particular problem.
> > > > >
> > > > > In column B, I have filled from row 2 to row 1250 with:
> > > > >
> > > > > =IF(blah blah,"",blah blah)
> > > > >
> > > > > To find the last row in the column that isn't blank, I tried:
> > > > >
> > > > > lr = Cells(Rows.Count, "B").End(xlUp).Row
> > > > >
> > > > > which returns the value of 1250.
> > > > >
> > > > > What I need is the last row in column B where the IF condition is FALSE, and
> > > > > there is text in that cell.
> > > > >
> > > > > TIA
> > > > > David

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column/Cell Question Stacy Microsoft Excel Misc 2 27th Aug 2008 09:50 PM
Sum Cell Values of one column based on Another Cell Value in a different column kristenb via OfficeKB.com Microsoft Excel Worksheet Functions 4 5th Feb 2008 03:33 PM
Maddening Dilemma - Compare each cell within column a to each cell in column b and find unique matches pogster@gmail.com Microsoft Excel Worksheet Functions 65 16th Nov 2007 07:27 PM
C# Excel multiple cell/column/row SQL Query Question rise4peace Microsoft C# .NET 2 31st Jan 2007 12:55 AM
Format cell in column B based on value in the next cell (column c) =?Utf-8?B?Tmljb2xl?= Microsoft Excel Misc 7 18th May 2005 10:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:20 AM.