Thread: CountA Problems
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul B Paul B is offline
external usenet poster
 
Posts: 709
Default CountA Problems

Robert, try this, you say from workbook to another workbook but then it
looks like you are going from worksheet to another worksheet, this is for
worksheet to worksheet

Sub cmdUpdateSales()

Sheets("Sales").Activate
Sheets("Sales").Select 'this may be overkill

NextRow = Application.CountA(Range("A1:A100")) + 1 'I want to count
'the rows on "Sales"

MsgBox NextRow

'More code here

End Sub

Don't know what the rest of your code is doing, or why you are adding 1 to
the count, maybe should be -1 to take out the header row?
most of the time you do not need to select a sheet or cells to work with
them so this should work also, but maybe not with the rest of your code, you
most likely can copy the data from one sheet to another one without
selecting it


Sub cmdUpdateSales2()

NextRow = Application.CountA(Sheets("Sales").Range("A1:A100" )) + 1 'I
want to count
'the rows on "Sales"

MsgBox NextRow

'More code here

End Sub



--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Robert Kedzie" wrote in message
news:Rmybe.3748$Zi.2923@fed1read04...
I plan to copy a few cells from a workbook "Store" to another one called
"Sales". I am putting this data into the worksheet in rows once a day. I

am
using a command button on Sheet("Store") to do this with the following

code:

Sub cmdUpdateSales()

Sheets("Sales").Activate
Sheets("Sales).Select 'this may be overkill

NextRow = Workbookfunction.CountA.Range("A1:A100") +1 'I want to

count
the rows on "Sales"

MsgBox NextRow

More code here

End Sub

The results of the message box show that 0 rows have been counted, because
the NextRow functions seems to counting on Sheet("Store") instead of
Sheet("Sales"). Sheet("Sales") does have a header row which should give a
row count of at least "1". What am I doing wrong? Can you help?

Thanks for the help

TucsonBob