Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default column count

just curious:

is there a way to get the number of columns using column numbers instead of
letters?

columns("K:BR").count
returns 60

but i'd like to use the column numbers instead.

--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default column count

You can use .column with cells

These formats also work

a = Range("A3:A7").Count

Returns 5

b = Range(Cells(1, 1), Cells(3, 3)).Count

Returns 9

"Gary Keramidas" wrote:

just curious:

is there a way to get the number of columns using column numbers instead of
letters?

columns("K:BR").count
returns 60

but i'd like to use the column numbers instead.

--


Gary




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default column count

? columns("K").Resize(,60).count
60


? Range(columns(11),columns(11+59)).count
60

--
Regards,
Tom Ogilvy


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
just curious:

is there a way to get the number of columns using column numbers instead
of letters?

columns("K:BR").count
returns 60

but i'd like to use the column numbers instead.

--


Gary





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default column count

got it, thanks

--


Gary


"Joel" wrote in message
...
You can use .column with cells

These formats also work

a = Range("A3:A7").Count

Returns 5

b = Range(Cells(1, 1), Cells(3, 3)).Count

Returns 9

"Gary Keramidas" wrote:

just curious:

is there a way to get the number of columns using column numbers instead of
letters?

columns("K:BR").count
returns 60

but i'd like to use the column numbers instead.

--


Gary






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default column count

thanks, to, i knew there was a way, just couldn't remember to use range.

--


Gary


"Tom Ogilvy" wrote in message
...
? columns("K").Resize(,60).count
60


? Range(columns(11),columns(11+59)).count
60

--
Regards,
Tom Ogilvy


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
just curious:

is there a way to get the number of columns using column numbers instead of
letters?

columns("K:BR").count
returns 60

but i'd like to use the column numbers instead.

--


Gary









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default column count

Gary,

Maybe I'm missing something, but if you already have the column numbers, why
can't you just subtract one from the other to get number of columns? E.g.,

Function NumCols(Col1 As Long, Col2 As Long)
NumCols = Abs(Col1 - Col2) + 1
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
just curious:

is there a way to get the number of columns using column numbers instead
of letters?

columns("K:BR").count
returns 60

but i'd like to use the column numbers instead.

--


Gary





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default column count


yes, chip, i thought of that a little bit ago. thanks for pointing that out,
too.
--


Gary


"Chip Pearson" wrote in message
...
Gary,

Maybe I'm missing something, but if you already have the column numbers, why
can't you just subtract one from the other to get number of columns? E.g.,

Function NumCols(Col1 As Long, Col2 As Long)
NumCols = Abs(Col1 - Col2) + 1
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
just curious:

is there a way to get the number of columns using column numbers instead of
letters?

columns("K:BR").count
returns 60

but i'd like to use the column numbers instead.

--


Gary







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to count#cells w/= value in other column and not count blank c aganoe Excel Worksheet Functions 4 April 9th 10 11:36 AM
Count Unique Values in 1 Column based on Date Range in another Column Brian Excel Worksheet Functions 14 May 17th 09 02:58 PM
Count Intervals of 1 Numeric value in a Row and Return Count down Column Sam via OfficeKB.com Excel Worksheet Functions 8 October 4th 05 04:37 PM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM
COUNT INFORMATION IN COLUMN B ONLY IF A1 MATCHES K1 COUNT THAT CE. witchcat98 Excel Worksheet Functions 1 February 4th 05 01:38 PM


All times are GMT +1. The time now is 09:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"