+ Reply to Thread
Results 1 to 10 of 10

multiple range

  1. #1
    Forum Contributor
    Join Date
    05-27-2004
    Posts
    119

    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

  2. #2
    Dave Peterson
    Guest

    Re: multiple range

    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. #3
    FSt1
    Guest

    RE: multiple range

    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. #4
    Forum Contributor
    Join Date
    05-27-2004
    Posts
    119
    Hi Mr.Dave Peterson,
    Done, thank u very much. It saves lot of time while running the macro.
    with regards
    nowfal

  5. #5
    Dave Peterson
    Guest

    Re: multiple range

    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. #6
    Forum Contributor
    Join Date
    05-27-2004
    Posts
    119

    http://www.excelforum.com/newreply.php?do=newreply&noquote=1&p=1051509#

    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

  7. #7
    Dave Peterson
    Guest

    Re: multiple range

    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").ClearContents

    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. #8
    Forum Contributor
    Join Date
    05-27-2004
    Posts
    119
    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

  9. #9
    Dave Peterson
    Guest

    Re: multiple range

    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").ClearContents

    (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. #10
    Dave Peterson
    Guest

    Re: multiple range

    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").ClearContents
    >
    > (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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1