#1   Report Post  
nowfal
 
Posts: n/a
Default multiple range


HI,
I would like to know to selected multiple ranges and clear the
contents
presently my code is like this:

Range("C2:L2").Select
Selection.ClearContents
Range("N2").Select
Selection.ClearContents
ActiveWindow.SmallScroll ToRight:=6
Range("O2:R2").Select
Selection.ClearContents
Range("T2:W2").Select
Selection.ClearContents

I wanted to writed in one line like:

Range("C2:L2","N2","O2:R2","T2:W2").Select
Selection.ClearContents


Any possibility.
thanks in advance
regards
nowfal


--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

How about:

Range("C2:L2,N2,O2:R2,T2:W2").ClearContents

No need to select first.

nowfal wrote:

HI,
I would like to know to selected multiple ranges and clear the
contents
presently my code is like this:

Range("C2:L2").Select
Selection.ClearContents
Range("N2").Select
Selection.ClearContents
ActiveWindow.SmallScroll ToRight:=6
Range("O2:R2").Select
Selection.ClearContents
Range("T2:W2").Select
Selection.ClearContents

I wanted to writed in one line like:

Range("C2:L2","N2","O2:R2","T2:W2").Select
Selection.ClearContents

Any possibility.
thanks in advance
regards
nowfal

--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092


--

Dave Peterson
  #3   Report Post  
FSt1
 
Posts: n/a
Default

hi
As you wished.
Range("C2,C2:L2,N2,O2:R2,T2:W2").Select

But you do know that N2,O2:R2 is the same as N2:R2.

Regards
FSt1

"nowfal" wrote:


HI,
I would like to know to selected multiple ranges and clear the
contents
presently my code is like this:

Range("C2:L2").Select
Selection.ClearContents
Range("N2").Select
Selection.ClearContents
ActiveWindow.SmallScroll ToRight:=6
Range("O2:R2").Select
Selection.ClearContents
Range("T2:W2").Select
Selection.ClearContents

I wanted to writed in one line like:

Range("C2:L2","N2","O2:R2","T2:W2").Select
Selection.ClearContents


Any possibility.
thanks in advance
regards
nowfal


--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092


  #4   Report Post  
nowfal
 
Posts: n/a
Default


Hi Mr.Dave Peterson,
Done, thank u very much. It saves lot
of time while running the macro.
with regards
nowfal


--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092

  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

Did you see FSt1's note:

But you do know that N2,O2:R2 is the same as N2:R2.

Sometimes, cleaning this kind of thing up when you notice it means you won't be
wondering why you did it that way before.


nowfal wrote:

Hi Mr.Dave Peterson,
Done, thank u very much. It saves lot
of time while running the macro.
with regards
nowfal

--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092


--

Dave Peterson


  #6   Report Post  
nowfal
 
Posts: n/a
Default


Hi Mr.Dave Peterson,
I saw his(FSt1) question, but it is
not inside that. N2 is separately cleaning , i wanna to avoid 5 cells
from clean ie. M2,S2,X2,AC2,AH2 b coz it contains formula that too the
macro unprotecting the sheet on the begining.

(Range("C2:H2,J2:L2,N2,O2:R2,T2:W2,Y2:AB2,AD2:AG2" ).ClearContents)

. As u said to be frank , 3 months before i was nothing (still i am a
KG student comparing guys like u) now atleast i can say i have done
some good work, which is using almost 50 people in different branches
of my company. So better portion of the credit goes to guys like u
Dave, Bob, etc etc . So keep it up helping others.
Thanks a lot
with regards


nowfal


--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092

  #7   Report Post  
Dave Peterson
 
Posts: n/a
Default

Fstl's point was that the cell N2 is inside the range O2:R2, so:

This formula
Range("C2:H2,J2:L2,N2,O2:R2,T2:W2,Y2:AB2,AD2:AG2") .ClearContents
is equivalent to:
Range("C2:H2,J2:L2,O2:R2,T2:W2,Y2:AB2,AD2:AG2").Cl earContents

You wouldn't have to specify N2, since it's in the middle of O2:R2.



nowfal wrote:

Hi Mr.Dave Peterson,
I saw his(FSt1) question, but it is
not inside that. N2 is separately cleaning , i wanna to avoid 5 cells
from clean ie. M2,S2,X2,AC2,AH2 b coz it contains formula that too the
macro unprotecting the sheet on the begining.

(Range("C2:H2,J2:L2,N2,O2:R2,T2:W2,Y2:AB2,AD2:AG2" ).ClearContents)

As u said to be frank , 3 months before i was nothing (still i am a
KG student comparing guys like u) now atleast i can say i have done
some good work, which is using almost 50 people in different branches
of my company. So better portion of the credit goes to guys like u
Dave, Bob, etc etc . So keep it up helping others.
Thanks a lot
with regards

nowfal

--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092


--

Dave Peterson
  #8   Report Post  
nowfal
 
Posts: n/a
Default


Hi Dave,
First of all, i dont like to argue with my teacher. So it
is not an argument, just to reply thats all.
AB CDEFGH I JKL M N OPQR STUVWXYZ.

I think u got it. N is not in the middle of OPQR. And I seperated the
N with a coma before and after. I think this confusion started by
Mr.Fstl. After all I dont want to eat your valuable time. Thanks for
the reply.
with regards
nowfal


--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092

  #9   Report Post  
Dave Peterson
 
Posts: n/a
Default

You are absolutely correct. (Stupid alphabet changes for me sometimes.)

Bun N2:R2 would include O2.

Range("C2:H2,J2:L2,N2:R2,T2:W2,Y2:AB2,AD2:AG2").Cl earContents

(I just screwed up FStl's note. It was my error, not his.)

nowfal wrote:

Hi Dave,
First of all, i dont like to argue with my teacher. So it
is not an argument, just to reply thats all.
AB CDEFGH I JKL M N OPQR STUVWXYZ.

I think u got it. N is not in the middle of OPQR. And I seperated the
N with a coma before and after. I think this confusion started by
Mr.Fstl. After all I dont want to eat your valuable time. Thanks for
the reply.
with regards
nowfal

--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092


--

Dave Peterson
  #10   Report Post  
Dave Peterson
 
Posts: n/a
Default

More problems with the alfabet/fingers!

Bun N2:R2 would include O2.
should be:
But N2:R2 would include O2.

Dave Peterson wrote:

You are absolutely correct. (Stupid alphabet changes for me sometimes.)

Bun N2:R2 would include O2.

Range("C2:H2,J2:L2,N2:R2,T2:W2,Y2:AB2,AD2:AG2").Cl earContents

(I just screwed up FStl's note. It was my error, not his.)

nowfal wrote:

Hi Dave,
First of all, i dont like to argue with my teacher. So it
is not an argument, just to reply thats all.
AB CDEFGH I JKL M N OPQR STUVWXYZ.

I think u got it. N is not in the middle of OPQR. And I seperated the
N with a coma before and after. I think this confusion started by
Mr.Fstl. After all I dont want to eat your valuable time. Thanks for
the reply.
with regards
nowfal

--
nowfal
------------------------------------------------------------------------
nowfal's Profile: http://www.excelforum.com/member.php...o&userid=10003
View this thread: http://www.excelforum.com/showthread...hreadid=392092


--

Dave Peterson


--

Dave Peterson
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
Dynamic named range across multiple sheets babycody Excel Discussion (Misc queries) 3 July 24th 05 06:03 AM
sum multiple criteria where final range is text? jt76 Excel Discussion (Misc queries) 0 May 25th 05 04:48 PM
Product Function in Pivot Tables from Multiple Consolidation Range bbishop222 Excel Worksheet Functions 0 February 22nd 05 04:55 PM
SUMIF multiple criteria in 1 range Mike@Q Excel Worksheet Functions 5 November 26th 04 03:55 PM
Sum a range across multiple sheets CarlosAntenna Excel Worksheet Functions 4 October 29th 04 12:22 PM


All times are GMT +1. The time now is 02:23 PM.

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"