best way to express the range "column N to column M"?

J

joeu2004

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.
 
I

isabelle

hi joeu2004,

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

isabelle

Le 2013-02-19 22:57, joeu2004 a écrit :
 
J

joeu2004

GS said:
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.
 
G

GS

joeu2004 laid this down on his screen :
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
 
G

GS

isabelle pretended :
;-)
isabelle

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top