Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default VBA to obtain Max Rows in any column in Used Reange

Excel 2003

What approach in VBA to get the maximum number of rows of actual data in any one column.
I do know how to get Rows & Columns in the Used Range - but I need cells with data not cells with
formatting.


My mind does not work well in the 3rd dimension - i.e. arrays.

The consepts which come to mind are MAX() and Array() and .End()

Can anyone help?


Thanks!

EagleOne
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,069
Default VBA to obtain Max Rows in any column in Used Reange

Here is sample code getting the last row with data two ways: once specifying
the column number, and once specifying the column letter.

Sub AAAAA()
Dim LastRow As Long
'With column as number.
LastRow& = Cells(Rows.Count, 3).End(xlUp).Row
MsgBox LastRow&
'With column as letter'
LastRow& = Range("C" & Rows.Count).End(xlUp).Row
MsgBox LastRow&
End Sub

Hope this helps,

Hutch

"donoteventry" <donoteventry, "removes"" wrote:

Excel 2003

What approach in VBA to get the maximum number of rows of actual data in any one column.
I do know how to get Rows & Columns in the Used Range - but I need cells with data not cells with
formatting.


My mind does not work well in the 3rd dimension - i.e. arrays.

The consepts which come to mind are MAX() and Array() and .End()

Can anyone help?


Thanks!

EagleOne

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default VBA to obtain Max Rows in any column in Used Reange

Tom,

Thanks for the reply. Your approach manually does one column at a time.

Is there not a way to obtain the Max Rows in any column?

EagleOne

Tom Hutchins wrote:

Here is sample code getting the last row with data two ways: once specifying
the column number, and once specifying the column letter.

Sub AAAAA()
Dim LastRow As Long
'With column as number.
LastRow& = Cells(Rows.Count, 3).End(xlUp).Row
MsgBox LastRow&
'With column as letter'
LastRow& = Range("C" & Rows.Count).End(xlUp).Row
MsgBox LastRow&
End Sub

Hope this helps,

Hutch

"donoteventry" <donoteventry, "removes"" wrote:

Excel 2003

What approach in VBA to get the maximum number of rows of actual data in any one column.
I do know how to get Rows & Columns in the Used Range - but I need cells with data not cells with
formatting.


My mind does not work well in the 3rd dimension - i.e. arrays.

The consepts which come to mind are MAX() and Array() and .End()

Can anyone help?


Thanks!

EagleOne

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 947
Default VBA to obtain Max Rows in any column in Used Reange

Is there not a way to obtain the Max Rows in any column?

One idea...

Sub LastRow()
Dim LastRow As Long
LastRow = Cells.Find( _
What:="*", _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
End Sub

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


<donoteventry; <removes; wrote in message
...
Tom,

Thanks for the reply. Your approach manually does one column at a time.

Is there not a way to obtain the Max Rows in any column?

EagleOne

Tom Hutchins wrote:

Here is sample code getting the last row with data two ways: once
specifying
the column number, and once specifying the column letter.

Sub AAAAA()
Dim LastRow As Long
'With column as number.
LastRow& = Cells(Rows.Count, 3).End(xlUp).Row
MsgBox LastRow&
'With column as letter'
LastRow& = Range("C" & Rows.Count).End(xlUp).Row
MsgBox LastRow&
End Sub

Hope this helps,

Hutch

"donoteventry" <donoteventry, "removes"" wrote:

Excel 2003

What approach in VBA to get the maximum number of rows of actual data in
any one column.
I do know how to get Rows & Columns in the Used Range - but I need cells
with data not cells with
formatting.


My mind does not work well in the 3rd dimension - i.e. arrays.

The consepts which come to mind are MAX() and Array() and .End()

Can anyone help?


Thanks!

EagleOne



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default VBA to obtain Max Rows in any column in Used Reange

By golly he hits a home run! Thanks!


"Dana DeLouis" wrote:

Is there not a way to obtain the Max Rows in any column?


One idea...

Sub LastRow()
Dim LastRow As Long
LastRow = Cells.Find( _
What:="*", _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
End Sub

Reply
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
repeat a formula same column same number of rows apart steveo Excel Discussion (Misc queries) 2 July 9th 06 04:34 AM
Return SEARCHED Column Number of Numeric Label and Value Sam via OfficeKB.com Excel Worksheet Functions 23 January 30th 06 06:16 PM
Need rows in Column A removed if they fully or partially match with any Column B row [email protected] Excel Discussion (Misc queries) 1 August 21st 05 11:41 PM
match and count words David Excel Worksheet Functions 5 July 4th 05 02:24 AM
moving alternating rows to a column with the order staying the sam Duke Carey Excel Discussion (Misc queries) 0 April 27th 05 09:51 PM


All times are GMT +1. The time now is 09:54 AM.

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

About Us

"It's about Microsoft Excel"