Counting number of columns

G

gatarossi

Dear all,

In my VBA code, I need to put a variable... The value of this variable
is the number of columns that there are values. For example:

A B C D E F G H ...
1 1 1 1 1

In this case the variable must be 5

Other Example

A B C D E F G H ...
1 1 1 1 1 1 1 1

In this case the variable must be 8

Thanks a lot!

André.
 
D

Dave Peterson

If the values are numeric:

Dim myCount as Long
mycount = application.count(worksheets("sheet9999").rows(2))

if the values are alphanumeric, use application.counta()

Remember that all formulas (including formulas that return "") will be counted
in .counta().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top