LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Error proof way to find first blank Row after Autofilter Range

Tom,

I'll also post the following as a new item is case you will not be available this weekend.

Ran into this challenge:

Set CurrRng = wks.Range(Cells(DataStartRow, DataTopCol).Address, _
Cells(wks.Cells(Rows.Count, "B").End(xlUp).Row, _
DataTopCol)).SpecialCells(xlCellTypeVisible)l


The code above yields: (CurrRng.address)

If CurrRng.SpecialCells(xlCellTypeVisible).Cells(1).R ows.Count = 1 (one data item row)
Then $1:$67,$149:$149,$332:$65536

If CurrRng.SpecialCells(xlCellTypeVisible).Cells(1).R ows.Count 1 (data item rows)
Then $149

The only data row visible is 149

The VBA code, after the "SET," crashes with $1:$67,$149:$149,$332:$65536
but is OK with $149

My current workaround is:

DataRowsCount = CurrRng.SpecialCells(xlCellTypeVisible).Cells(1).R ows.Count
Set CurrRng = wks.Range(Cells(DataStartRow + IIf(DataRowsCount = 1, 1, 0), _
DataTopCol).Address, Cells(wks.Cells(Rows.Count, "B").End(xlUp).Row, _
DataTopCol)).SpecialCells(xlCellTypeVisible)

What causes the different results?

I really appreciate your thoughts and time

EagleOne

Tom Ogilvy wrote:

Yes you did, but if you know you will have an autofilter range that contains
the last used row in your sheet, then your one liner will be sufficient
whether the sheet is in filtermode or not. (rows hidden by the filter or not)

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find last non-blank cell in range Eric Excel Discussion (Misc queries) 11 February 11th 09 07:31 PM
Find within range & Replace with Blank Value JG14 Excel Discussion (Misc queries) 4 July 13th 07 05:06 PM
How do I find the next blank cell in a range? EazyCure Excel Worksheet Functions 6 June 11th 07 09:14 PM
find range of non-blank cells in colum DJS Excel Programming 3 June 26th 06 10:27 PM
How to find the first blank cell in a range Victor[_3_] Excel Programming 11 November 6th 03 03:20 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"