+ 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    [email protected]
    "Andy Chan" <[email protected]> wrote in message
    news:[email protected]...
    > 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"
    <[email protected]> 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" <[email protected]>
    ???????:[email protected]...
    > 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" <[email protected]> 撰寫於郵件新聞:uNJtL%[email protected]...
    > another from anywhere in the workbook
    >
    > Sub selectpartofnamedrng()
    > Application.Goto [rng].Rows("1:10")
    > End Sub
    >
    > --
    > Don Guillett
    > SalesAid Software
    > [email protected]
    > "Andy Chan" <[email protected]> wrote in message
    > news:[email protected]...
    >> 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" <[email protected]> 撰寫於郵件新聞:Iy%[email protected]...
    >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" <[email protected]> wrote in message
    > news:[email protected]...
    >> 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" <[email protected]>
    ???????:[email protected]...
    > On Sat, 4 Feb 2006 17:18:23 +0800, "Andy Chan"
    > <[email protected]> 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