Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Determining the number of cells with data in a column

I know this has to be real simple, but I can't find an answer.

I have a column ("A") of data on a sheet ("OldFiles") and I just need to
know how many cells are in that column have data in them. The column is
sorted, so the non-blank cells will be contiguous and will be at the top of
the column.

TIA,
Ken




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Determining the number of cells with data in a column

set rng = Cells(rows.count,1).End(xlup).Row

msgbox rng.row

--
Regards,
Tom Ogilvy

"Ken Loomis" wrote in message
...
I know this has to be real simple, but I can't find an answer.

I have a column ("A") of data on a sheet ("OldFiles") and I just need to
know how many cells are in that column have data in them. The column is
sorted, so the non-blank cells will be contiguous and will be at the top

of
the column.

TIA,
Ken






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Determining the number of cells with data in a column

Try
num = worksheetfunction.counta(columns(1))

formula in worksheet =Counta(A:A)
--
steveB

Remove "AYN" from email to respond
"Ken Loomis" wrote in message
...
I know this has to be real simple, but I can't find an answer.

I have a column ("A") of data on a sheet ("OldFiles") and I just need to
know how many cells are in that column have data in them. The column is
sorted, so the non-blank cells will be contiguous and will be at the top
of the column.

TIA,
Ken






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Determining the number of cells with data in a column

Here's where I always get so confused.

I think your suggested code, Tom, work with the active worksheet.

I was wanting to do that without selecting the worksheet. It's a hidden
worksheet.

So I tried this:

Set rng = Sheets("OldFiles").Cells(Rows.count, 1).End(xlUp).Row
FilesOnSheet = rng.Row


But with that, I get a:

Run-time error '13':
Type mismatch


What am I doing wrong and what am I not getting about this? Is it my lack of
understanding about the Object Model? And, if so, can someone point me in
the direction of something that will help me better understand that?

TIA,
Ken





"Tom Ogilvy" wrote in message
...
set rng = Cells(rows.count,1).End(xlup).Row

msgbox rng.row

--
Regards,
Tom Ogilvy

"Ken Loomis" wrote in message
...
I know this has to be real simple, but I can't find an answer.

I have a column ("A") of data on a sheet ("OldFiles") and I just need to
know how many cells are in that column have data in them. The column is
sorted, so the non-blank cells will be contiguous and will be at the top

of
the column.

TIA,
Ken








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Determining the number of cells with data in a column

Well, that is my fault about the error:

Set rng = Sheets("OldFiles").Cells(Rows.count, 1).End(xlUp)
FilesOnSheet = rng.Row

or

lastrow = = Sheets("OldFiles").Cells(Rows.count, 1).End(xlUp).row

Sometime one changes their mind in the middle of writing the code.

--
Regards,
Tom Ogilvy


"Ken Loomis" wrote in message
...
Here's where I always get so confused.

I think your suggested code, Tom, work with the active worksheet.

I was wanting to do that without selecting the worksheet. It's a hidden
worksheet.

So I tried this:

Set rng = Sheets("OldFiles").Cells(Rows.count, 1).End(xlUp).Row
FilesOnSheet = rng.Row


But with that, I get a:

Run-time error '13':
Type mismatch


What am I doing wrong and what am I not getting about this? Is it my lack

of
understanding about the Object Model? And, if so, can someone point me in
the direction of something that will help me better understand that?

TIA,
Ken





"Tom Ogilvy" wrote in message
...
set rng = Cells(rows.count,1).End(xlup).Row

msgbox rng.row

--
Regards,
Tom Ogilvy

"Ken Loomis" wrote in message
...
I know this has to be real simple, but I can't find an answer.

I have a column ("A") of data on a sheet ("OldFiles") and I just need

to
know how many cells are in that column have data in them. The column is
sorted, so the non-blank cells will be contiguous and will be at the

top
of
the column.

TIA,
Ken












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Determining the number of cells with data in a column

Thanks again, Tom.

As always, that worked great.

Ken


"Tom Ogilvy" wrote in message
...
Well, that is my fault about the error:

Set rng = Sheets("OldFiles").Cells(Rows.count, 1).End(xlUp)
FilesOnSheet = rng.Row

or

lastrow = = Sheets("OldFiles").Cells(Rows.count, 1).End(xlUp).row

Sometime one changes their mind in the middle of writing the code.

--
Regards,
Tom Ogilvy


"Ken Loomis" wrote in message
...
Here's where I always get so confused.

I think your suggested code, Tom, work with the active worksheet.

I was wanting to do that without selecting the worksheet. It's a hidden
worksheet.

So I tried this:

Set rng = Sheets("OldFiles").Cells(Rows.count, 1).End(xlUp).Row
FilesOnSheet = rng.Row


But with that, I get a:

Run-time error '13':
Type mismatch


What am I doing wrong and what am I not getting about this? Is it my lack

of
understanding about the Object Model? And, if so, can someone point me in
the direction of something that will help me better understand that?

TIA,
Ken





"Tom Ogilvy" wrote in message
...
set rng = Cells(rows.count,1).End(xlup).Row

msgbox rng.row

--
Regards,
Tom Ogilvy

"Ken Loomis" wrote in message
...
I know this has to be real simple, but I can't find an answer.

I have a column ("A") of data on a sheet ("OldFiles") and I just need

to
know how many cells are in that column have data in them. The column
is
sorted, so the non-blank cells will be contiguous and will be at the

top
of
the column.

TIA,
Ken












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
Determining row number in which a value occurs Harold Christian[_2_] Charts and Charting in Excel 1 February 17th 09 08:33 AM
Determining the highest number in a row Jaydubs Excel Discussion (Misc queries) 4 December 7th 05 03:10 PM
Determining the highest number in a row Jaydubs Excel Discussion (Misc queries) 1 December 7th 05 03:05 PM
Determining new category number Matt[_22_] Excel Programming 0 November 5th 03 08:53 PM
Determining Row Number Wes Jester Excel Programming 2 August 26th 03 09:20 PM


All times are GMT +1. The time now is 01:17 PM.

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"