PC Review


Reply
Thread Tools Rate Thread

How to Count Columns

 
 
gatarossi@ig.com.br
Guest
Posts: n/a
 
      14th Sep 2007
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é.

 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      14th Sep 2007
do until count=cells(4,columns.count).end(xltoleft).column

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
<(E-Mail Removed)> wrote in message
news:(E-Mail 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é.

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      14th Sep 2007
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




(E-Mail Removed) wrote:
>
> 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é.


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to count on two columns Debbi Microsoft Excel Worksheet Functions 1 13th Mar 2009 01:13 AM
Count of Different Columns Andy Microsoft Excel Misc 5 26th Nov 2008 09:44 AM
Count columns Igor G. Microsoft Access Queries 1 31st Jul 2008 01:19 PM
Count Across Columns Craig Microsoft Access Queries 2 25th Jun 2007 08:16 PM
Req: Count of Two Columns kenneth_lad Microsoft Access Queries 2 16th Feb 2004 10:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:12 AM.