ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   WorksheetFunction Calculation Error (https://www.excelbanter.com/excel-programming/440439-worksheetfunction-calculation-error.html)

Ayo

WorksheetFunction Calculation Error
 
errorWS.Range("B3").Value = Application.WorksheetFunction.CountA("A5:A" &
errorWS_startRow - 1)

The above line of code is always 1, even when errorWS_startRow is much 1,
i.e:
errorWS_startRow=144, 749 etc.

Any ideas what is going on?

ker_01

WorksheetFunction Calculation Error
 
I'd suggest including the sheet reference for the CountA; something like this
(untested)

errorWS.Range("B3").Value =
Application.WorksheetFunction.CountA(errorWS.Range ("A5:A" &
errorWS_startRow - 1))

"Ayo" wrote:

errorWS.Range("B3").Value = Application.WorksheetFunction.CountA("A5:A" &
errorWS_startRow - 1)

The above line of code is always 1, even when errorWS_startRow is much 1,
i.e:
errorWS_startRow=144, 749 etc.

Any ideas what is going on?


JLGWhiz[_2_]

WorksheetFunction Calculation Error
 
If the cells from A5 to A & errorWS_startRow-1 are empty, you will get
either 1 or zero depending on whether there is data in the startRow - 1 or
not. CountA only counts cells with data that has a value. It will not
count empty cells but does count cells with zero, "" or ' characters that
are hidden because they have values. So, the range you are testing must be
empty except for one cell.



"Ayo" wrote in message
...
errorWS.Range("B3").Value = Application.WorksheetFunction.CountA("A5:A" &
errorWS_startRow - 1)

The above line of code is always 1, even when errorWS_startRow is much
1,
i.e:
errorWS_startRow=144, 749 etc.

Any ideas what is going on?





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com