Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / September 2007

Tip: Looking for answers? Try searching our database.

How to Count Columns

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gatarossi@ig.com.br - 14 Sep 2007 20:55 GMT
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é.
Don Guillett - 14 Sep 2007 21:14 GMT
do until count=cells(4,columns.count).end(xltoleft).column

Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

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 - 14 Sep 2007 21:21 GMT
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

> Dear all,
>
[quoted text clipped - 18 lines]
>
> André.

Signature

Dave Peterson


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.