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
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
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
>
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
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
>
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
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
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
>>
>
>
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
>>
>
>
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks