Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default best way to express the range "column N to column M"?

I often myself writing algorithms wherein I want to reference "column N to
column M", where N and M are numbers. For example, I want to write:

Columns(N & ":" & M).Clear

Instead, I seem to have to write:

Range(Cells(1,N),Cells(1,M)).EntireColumn.Clear

Is that the best I can do? Or is there a more efficient way to refer a
range of columns by number?

PS: It seem odd that Columns(2) works, and the "quick info" editing tips
shows Columns(RowIndex,ColumnIndex), but Columns(2,3) does not work.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default best way to express the range "column N to column M"?

Try...

Range(Columns(N), Columns(M)).Clear

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default best way to express the range "column N to column M"?

hi joeu2004,

Columns("M:N").Clear
or
Range(Columns(13), Columns(14)).Clear

isabelle

Le 2013-02-19 22:57, joeu2004 a écrit :
I often myself writing algorithms wherein I want to reference "column N
to column M", where N and M are numbers. For example, I want to write:

Columns(N & ":" & M).Clear

Instead, I seem to have to write:

Range(Cells(1,N),Cells(1,M)).EntireColumn.Clear

Is that the best I can do? Or is there a more efficient way to refer a
range of columns by number?

PS: It seem odd that Columns(2) works, and the "quick info" editing
tips shows Columns(RowIndex,ColumnIndex), but Columns(2,3) does not work.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default best way to express the range "column N to column M"?

also,

Range("M1:N1").EntireColumn.Clear

isabelle

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default best way to express the range "column N to column M"?

"GS" wrote:
Range(Columns(N), Columns(M)).Clear


Thanks. Definitely better.

And you correctly understood that I meant to write: N and M are numeric
variables, not numbers per se.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default best way to express the range "column N to column M"?

joeu2004 laid this down on his screen :
"GS" wrote:
Range(Columns(N), Columns(M)).Clear


Thanks. Definitely better.


You're welcome!

And you correctly understood that I meant to write: N and M are numeric
variables, not numbers per se.


Yes, you made that quite clear. I'm not sure how Isabelle missed that!!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default best way to express the range "column N to column M"?

;-)
isabelle

Le 2013-02-20 14:10, GS a écrit :

Yes, you made that quite clear. I'm not sure how Isabelle missed that!!

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default best way to express the range "column N to column M"?

isabelle pretended :
;-)
isabelle

Le 2013-02-20 14:10, GS a écrit :

Yes, you made that quite clear. I'm not sure how Isabelle missed that!!


Isabelle,
I suspected you were either tired or in a hurry because normally that
wouldn't have slipped past you!<g ^^

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
macro is to update column 13 and 14 of worksheet "Voice BB Pending"as per column 2 and 3 of "Activity log" . San[_3_] Excel Programming 1 August 19th 10 11:19 AM
How do I change the column heading in Excel to display "A" "B" "C Thai New Users to Excel 1 November 30th 07 08:06 PM
how can I count if column A="active" and column E="Job" in a list? Brandoni Excel Worksheet Functions 1 October 14th 06 09:09 AM
Please add a "sheet" function like "row" and "column" functions Spreadsheet Monkey Excel Programming 2 November 8th 05 04:08 PM
How do I split "A1B2" into "A1" and "B2" using text to column fun. Jennifer Excel Programming 1 February 2nd 05 10:01 PM


All times are GMT +1. The time now is 01:55 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"