PC Review


Reply
Thread Tools Rate Thread

column.count 99

 
 
=?Utf-8?B?UmF5?=
Guest
Posts: n/a
 
      17th May 2006
Can anyone provide the syntax for counting the number of columns containing
data in an unknown range? The row.count syntax is:
lastrow = Worksheets(1).Cells(Rows.Count, 2).End(xlUp).Row
lastcolumn=???

I need to find the last column with data in a worksheet that could contain
any number of columns.
--
Ray
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      17th May 2006
You used column B to find the last row.

Can you pick out a row to find the last column (maybe row 1 has headers???):

dim LastRow as long
dim LastCol as long

With worksheets(1)
lastrow = .Cells(Rows.Count, 2).End(xlUp).Row
lastcol = .cells(1,.columns.count).end(xltoleft).column
end with



Ray wrote:
>
> Can anyone provide the syntax for counting the number of columns containing
> data in an unknown range? The row.count syntax is:
> lastrow = Worksheets(1).Cells(Rows.Count, 2).End(xlUp).Row
> lastcolumn=???
>
> I need to find the last column with data in a worksheet that could contain
> any number of columns.
> --
> Ray


--

Dave Peterson
 
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
how to count#cells w/= value in other column and not count blank c aganoe Microsoft Excel Worksheet Functions 4 9th Apr 2010 11:36 AM
Count Unique Values in 1 Column based on Date Range in another Column Brian Microsoft Excel Worksheet Functions 0 16th May 2009 04:44 PM
Count Intervals of 1 Numeric value in a Row and Return Count down Column Sam via OfficeKB.com Microsoft Excel Worksheet Functions 8 4th Oct 2005 04:37 PM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Microsoft Excel Worksheet Functions 9 31st Jul 2005 03:37 AM
COUNT INFORMATION IN COLUMN B ONLY IF A1 MATCHES K1 COUNT THAT CE. =?Utf-8?B?d2l0Y2hjYXQ5OA==?= Microsoft Excel Worksheet Functions 1 4th Feb 2005 01:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:38 AM.