+ Reply to Thread
Results 1 to 9 of 9

Selection within a named range

  1. #1
    Andy Chan
    Guest

    Selection within a named range

    Dear all,

    There is a named range "Rng" in my workbook. I want to write a VBA
    program to select the first 10 rows of the range "Rng". What code should I
    write?

    Best Regards,
    Andy



  2. #2
    Ian
    Guest

    Re: Selection within a named range

    I don't know how you could do this, but you could create another named range
    consisting of the area you want.

    --
    Ian
    --
    "Andy Chan" <chankhandy-msnewsgroup@yahoo.com.hk> wrote in message
    news:43e4715e@127.0.0.1...
    > Dear all,
    >
    > There is a named range "Rng" in my workbook. I want to write a VBA
    > program to select the first 10 rows of the range "Rng". What code should I
    > write?
    >
    > Best Regards,
    > Andy
    >




  3. #3
    Dave Peterson
    Guest

    Re: Selection within a named range

    Option Explicit
    Sub testme()
    Dim myRng As Range
    Set myRng = Worksheets("sheet1").Range("Rng").Areas(1).Resize(10)
    Application.Goto myRng
    End Sub

    ..areas(1) is nice if you have multiple areas in that range.

    ..resize(x,y) says to adjust the range to be x rows and y columns. If you omit
    one of those x,y's, then it doesn't change that row/column

    ..resize(10) says 10 rows -- same number of columns
    ..resize(,4) says same number of rows -- 4 columns

    ..resize(11,33) says 11 rows -- 33 columns.


    Andy Chan wrote:
    >
    > Dear all,
    >
    > There is a named range "Rng" in my workbook. I want to write a VBA
    > program to select the first 10 rows of the range "Rng". What code should I
    > write?
    >
    > Best Regards,
    > Andy


    --

    Dave Peterson

  4. #4
    Don Guillett
    Guest

    Re: Selection within a named range

    another from anywhere in the workbook

    Sub selectpartofnamedrng()
    Application.Goto [rng].Rows("1:10")
    End Sub

    --
    Don Guillett
    SalesAid Software
    dguillett1@austin.rr.com
    "Andy Chan" <chankhandy-msnewsgroup@yahoo.com.hk> wrote in message
    news:43e4715e@127.0.0.1...
    > Dear all,
    >
    > There is a named range "Rng" in my workbook. I want to write a VBA
    > program to select the first 10 rows of the range "Rng". What code should I
    > write?
    >
    > Best Regards,
    > Andy
    >




  5. #5
    Ron Rosenfeld
    Guest

    Re: Selection within a named range

    On Sat, 4 Feb 2006 17:18:23 +0800, "Andy Chan"
    <chankhandy-msnewsgroup@yahoo.com.hk> wrote:

    >Dear all,
    >
    > There is a named range "Rng" in my workbook. I want to write a VBA
    >program to select the first 10 rows of the range "Rng". What code should I
    >write?
    >
    >Best Regards,
    >Andy
    >


    This seems to work also:

    ========================
    Sub foo()
    Dim SmallRange As Range

    Set SmallRange = Range("Rng").Range(Cells(1, 1), Cells(10, 1))
    Debug.Print SmallRange.Address
    SmallRange.Select

    End Sub
    ==========================

    or, more simply doing just exactly what you requested:

    =======================
    Range("rng").Range(Cells(1, 1), Cells(10, 1)).Select
    ========================


    --ron

  6. #6
    Andy Chan
    Guest

    Re: Selection within a named range

    Thanks all!
    I have completed my task!

    "Dave Peterson" <petersod@verizonXSPAM.net>
    ???????:43E497C6.B4CCC282@verizonXSPAM.net...
    > Option Explicit
    > Sub testme()
    > Dim myRng As Range
    > Set myRng = Worksheets("sheet1").Range("Rng").Areas(1).Resize(10)
    > Application.Goto myRng
    > End Sub
    >
    > .areas(1) is nice if you have multiple areas in that range.
    >
    > .resize(x,y) says to adjust the range to be x rows and y columns. If you
    > omit
    > one of those x,y's, then it doesn't change that row/column
    >
    > .resize(10) says 10 rows -- same number of columns
    > .resize(,4) says same number of rows -- 4 columns
    >
    > .resize(11,33) says 11 rows -- 33 columns.
    >
    >
    > Andy Chan wrote:
    >>
    >> Dear all,
    >>
    >> There is a named range "Rng" in my workbook. I want to write a VBA
    >> program to select the first 10 rows of the range "Rng". What code should
    >> I
    >> write?
    >>
    >> Best Regards,
    >> Andy

    >
    > --
    >
    > Dave Peterson




  7. #7
    Andy Chan
    Guest

    Re: Selection within a named range

    Thanks all!
    I have completed my task!
    "Don Guillett" <dguillett1@austin.rr.com> 撰寫於郵件新聞:uNJtL%23YKGHA.2336@TK2MSFTNGP12.phx.gbl...
    > another from anywhere in the workbook
    >
    > Sub selectpartofnamedrng()
    > Application.Goto [rng].Rows("1:10")
    > End Sub
    >
    > --
    > Don Guillett
    > SalesAid Software
    > dguillett1@austin.rr.com
    > "Andy Chan" <chankhandy-msnewsgroup@yahoo.com.hk> wrote in message
    > news:43e4715e@127.0.0.1...
    >> Dear all,
    >>
    >> There is a named range "Rng" in my workbook. I want to write a VBA
    >> program to select the first 10 rows of the range "Rng". What code should
    >> I write?
    >>
    >> Best Regards,
    >> Andy
    >>

    >
    >




  8. #8
    Andy Chan
    Guest

    Re: Selection within a named range

    Thanks all!
    I have completed my task!
    "Ian" <me@me.com> 撰寫於郵件新聞:Iy%Ef.7015$Fy4.5441@newsfe4-win.ntli.net...
    >I don't know how you could do this, but you could create another named
    >range consisting of the area you want.
    >
    > --
    > Ian
    > --
    > "Andy Chan" <chankhandy-msnewsgroup@yahoo.com.hk> wrote in message
    > news:43e4715e@127.0.0.1...
    >> Dear all,
    >>
    >> There is a named range "Rng" in my workbook. I want to write a VBA
    >> program to select the first 10 rows of the range "Rng". What code should
    >> I write?
    >>
    >> Best Regards,
    >> Andy
    >>

    >
    >




  9. #9
    Andy Chan
    Guest

    Re: Selection within a named range

    Thanks all!
    I have completed my task!
    "Ron Rosenfeld" <ronrosenfeld@nospam.org>
    ???????:p8b9u15t7iaa2v03qqkgqv4f7rgjvl4l8a@4ax.com...
    > On Sat, 4 Feb 2006 17:18:23 +0800, "Andy Chan"
    > <chankhandy-msnewsgroup@yahoo.com.hk> wrote:
    >
    >>Dear all,
    >>
    >> There is a named range "Rng" in my workbook. I want to write a VBA
    >>program to select the first 10 rows of the range "Rng". What code should I
    >>write?
    >>
    >>Best Regards,
    >>Andy
    >>

    >
    > This seems to work also:
    >
    > ========================
    > Sub foo()
    > Dim SmallRange As Range
    >
    > Set SmallRange = Range("Rng").Range(Cells(1, 1), Cells(10, 1))
    > Debug.Print SmallRange.Address
    > SmallRange.Select
    >
    > End Sub
    > ==========================
    >
    > or, more simply doing just exactly what you requested:
    >
    > =======================
    > Range("rng").Range(Cells(1, 1), Cells(10, 1)).Select
    > ========================
    >
    >
    > --ron




+ 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