How to Count Columns

  • Thread starter Thread starter gatarossi
  • Start date Start date
G

gatarossi

Dear all,

I need to do a code until the last column with data in one line, but
in this code belown, if there is a column with no data, the code
doesn't work very well, because it doesn't count this column.

count = 1
col = Application.CountA(Worksheets("resume").Rows(4))

Do Until count = col

A B C D E F G H I ...
1 2 3 4 5 6 7

With this variant, the code will run until the number 7 because col is
equal 7, but I need that the code run until 9.

How can I solve this problem? I have different number of columns!

Thanks in advance!!!

André.
 
do until count=cells(4,columns.count).end(xltoleft).column

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Dear all,

I need to do a code until the last column with data in one line, but
in this code belown, if there is a column with no data, the code
doesn't work very well, because it doesn't count this column.

count = 1
col = Application.CountA(Worksheets("resume").Rows(4))

Do Until count = col

A B C D E F G H I ...
1 2 3 4 5 6 7

With this variant, the code will run until the number 7 because col is
equal 7, but I need that the code run until 9.

How can I solve this problem? I have different number of columns!

Thanks in advance!!!

André.
 
Maybe...

dim LastCol as long
dim myCount as long 'I wouldn't use a variable named Count

with worksheets("resume")
LastCol = .cells(4,.columns.count).end(xltoleft).column
'rest of code here
 
Back
Top