Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheetfunction-countA----please help

Hello,
I am having some difficulty with this function...can someone assist?
I am trying to count the number of non-empty (text data) cells in a
given array of cells within a worksheet using vba. The problem is that
Worksheetfunction.counta does not return the right number of cells
containing text info when there is data in column 42 or 46 or 50. But
seems to work okay upto column 38. The code I use is provided below.
When I execute the code in stepwise mode, it shows the data for columns
18,22,26,30,34 and 36. But when the cursor is placed over the
cells(Row,38, 42, 46, or 50)...it does not show to contain data even
though data is present. Is there error in the code I use?

With Sheets("Data")
For Row = 4 To lastr
c = WorksheetFunction.CountA(.Cells(Row, 18), .Cells(Row, 22), _
.Cells(Row, 26), .Cells(Row, 30), .Cells(Row, 34), .Cells(Row, 38) _
.Cells(Row, 42), .Cells(Row, 46), .Cells(Row, 50)) ' # items.

etc
c is not correct for values greater than 5
Thanks

Ally

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Worksheetfunction-countA----please help

Ally,

Try

c = WorksheetFunction.CountA(Range("R" & Row & ",V" & Row & ",Z" & Row &
_
",AD" & Row & ",AH" & Row & ",AJ" &
Row & _
",AL" & Row & ",AN" & Row & ",AT" &
Row & _
",AX" & Row)) ' # items.


--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
oups.com...
Hello,
I am having some difficulty with this function...can someone assist?
I am trying to count the number of non-empty (text data) cells in a
given array of cells within a worksheet using vba. The problem is that
Worksheetfunction.counta does not return the right number of cells
containing text info when there is data in column 42 or 46 or 50. But
seems to work okay upto column 38. The code I use is provided below.
When I execute the code in stepwise mode, it shows the data for columns
18,22,26,30,34 and 36. But when the cursor is placed over the
cells(Row,38, 42, 46, or 50)...it does not show to contain data even
though data is present. Is there error in the code I use?

With Sheets("Data")
For Row = 4 To lastr
c = WorksheetFunction.CountA(.Cells(Row, 18), .Cells(Row, 22), _
.Cells(Row, 26), .Cells(Row, 30), .Cells(Row, 34), .Cells(Row, 38) _
.Cells(Row, 42), .Cells(Row, 46), .Cells(Row, 50)) ' # items.

etc
c is not correct for values greater than 5
Thanks

Ally



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
Can't use WorksheetFunction Yossi Excel Discussion (Misc queries) 5 January 25th 06 10:07 PM
WorksheetFunction.CountA - Excel 2000, Please help microsoft[_6_] Excel Programming 1 April 22nd 05 03:50 AM
COUNTA Function not working =COUNTA(C3:C69,"NH") MikeinNH Excel Worksheet Functions 2 November 8th 04 01:19 AM
Worksheetfunction Fred Smith Excel Programming 5 May 14th 04 01:11 AM
WorkSheetFunction.CountIf & WorkSheetFunction.SumIf with 2 conditions? Etien[_2_] Excel Programming 3 January 13th 04 04:07 PM


All times are GMT +1. The time now is 09:55 PM.

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"