PDA

View Full Version : Solved: DynamicColumn Count



bob1122
09-02-2008, 08:41 AM
I want to include the count of the number of columns in a worksheet, where the number of columns may change, in a macro.

In Excel the following returns the correct column count:
= CountA($1:$1)

In a macro, the following returns a result of "1" instead of the correct column count:
colkount=WorksheetFunction.CountA("$1:$1)"

How can I get the correct column in a macro? thanks

Bob Phillips
09-02-2008, 08:52 AM
Try



colkCount = application.CountA(range("1:1"))

bob1122
09-02-2008, 09:07 AM
Thanks very much!