Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default tip: extending a range

Many people just use rows(n).Insert to extend a range
supposing you want ot extend teh range without the insert?
Here's one way :

Option Explicit
Sub test()
addRows Worksheets("sheet1").Range("myrange"), 2
End Sub
Sub addRows(target As Range, howmany As Long)
With target
With .Resize(.Rows.Count + howmany)
.Name = target.Name.Name
End With
End With
End Sub


you may want to add colr, borders etc...
I hope this may help somebody - and it may give you ideas.

Patrick


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default extending a range

Instead of making the user construct a range to pass into your AddRows
subroutine, why not just let them pass the Defined Name in and just process
that...

Sub AddRows(DefinedName As String, HowMany As Long)
With Names(DefinedName).RefersToRange
.Resize(.Rows.Count + HowMany).Name = .Name.Name
End With
End Sub

--
Rick (MVP - Excel)


"Patrick Molloy" wrote in message
...
Many people just use rows(n).Insert to extend a range
supposing you want ot extend teh range without the insert?
Here's one way :

Option Explicit
Sub test()
addRows Worksheets("sheet1").Range("myrange"), 2
End Sub
Sub addRows(target As Range, howmany As Long)
With target
With .Resize(.Rows.Count + howmany)
.Name = target.Name.Name
End With
End With
End Sub


you may want to add colr, borders etc...
I hope this may help somebody - and it may give you ideas.

Patrick



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default extending a range

good idea - thats what I'd do.

This is intended to open up ideas. so thanks very much

"Rick Rothstein" wrote:

Instead of making the user construct a range to pass into your AddRows
subroutine, why not just let them pass the Defined Name in and just process
that...

Sub AddRows(DefinedName As String, HowMany As Long)
With Names(DefinedName).RefersToRange
.Resize(.Rows.Count + HowMany).Name = .Name.Name
End With
End Sub

--
Rick (MVP - Excel)


"Patrick Molloy" wrote in message
...
Many people just use rows(n).Insert to extend a range
supposing you want ot extend teh range without the insert?
Here's one way :

Option Explicit
Sub test()
addRows Worksheets("sheet1").Range("myrange"), 2
End Sub
Sub addRows(target As Range, howmany As Long)
With target
With .Resize(.Rows.Count + howmany)
.Name = target.Name.Name
End With
End With
End Sub


you may want to add colr, borders etc...
I hope this may help somebody - and it may give you ideas.

Patrick




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
Extending a range selection Mats Samson Excel Programming 14 April 21st 08 10:47 PM
Extending a range Macca1984 Excel Discussion (Misc queries) 5 March 6th 08 11:36 AM
Extending a range Macca1984 Excel Programming 0 March 5th 08 09:58 PM
Automatically extending a range Oldjay Excel Programming 1 April 30th 07 03:04 AM
help extending formula to range pgd Excel Programming 4 October 16th 05 10:36 PM


All times are GMT +1. The time now is 12:07 AM.

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"