PC Review


Reply
Thread Tools Rate Thread

Add a Dynamic Name Range

 
 
Fredriksson via OfficeKB.com
Guest
Posts: n/a
 
      3rd Apr 2007
Using This Workbook module, I need to set up Name Ranges everytime the Work
Book is Open but the size of the range may change between each opening and
the user may delete a range when open.

When I recorded a Name defining Macro, it produce this code.
ActiveWorkbook.Names.Add Name:="CompanyXrefRange", RefersToR1C1:= _
"='Xref Property'!R2C1:R3182C4"

When I resize the range in my code I use this code
CompanyXrefRange.Resize(CompanyData.Rows.Count + 1, CompanyData.Columns.Count)
Name = "CompanyXrefRange"

Can I combine the two concept above so when This Workbook is executed it will
coount the rows and the columns to create the appropriate size of the Range

Thanks

--
Message posted via http://www.officekb.com

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      3rd Apr 2007
Try this

ActiveWorkbook.Cells(CompanyData.Rows.Count + 1,
CompanyData.Columns.Count).Name="CompanyXrefRange"

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Fredriksson via OfficeKB.com" <u27002@uwe> wrote in message
news:70295e96df0ca@uwe...
> Using This Workbook module, I need to set up Name Ranges everytime the
> Work
> Book is Open but the size of the range may change between each opening and
> the user may delete a range when open.
>
> When I recorded a Name defining Macro, it produce this code.
> ActiveWorkbook.Names.Add Name:="CompanyXrefRange", RefersToR1C1:= _
> "='Xref Property'!R2C1:R3182C4"
>
> When I resize the range in my code I use this code
> CompanyXrefRange.Resize(CompanyData.Rows.Count + 1,
> CompanyData.Columns.Count)
> Name = "CompanyXrefRange"
>
> Can I combine the two concept above so when This Workbook is executed it
> will
> coount the rows and the columns to create the appropriate size of the
> Range
>
> Thanks
>
> --
> Message posted via http://www.officekb.com
>



 
Reply With Quote
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      3rd Apr 2007
When you set up the named range you could do something like this:

=offset(Sheet1!$A$1,0,0,counta($A:$A),counta($1:$1))

It will dynamically expand and contract as needed. Let me know if that's
what you need.


"Fredriksson via OfficeKB.com" wrote:

> Using This Workbook module, I need to set up Name Ranges everytime the Work
> Book is Open but the size of the range may change between each opening and
> the user may delete a range when open.
>
> When I recorded a Name defining Macro, it produce this code.
> ActiveWorkbook.Names.Add Name:="CompanyXrefRange", RefersToR1C1:= _
> "='Xref Property'!R2C1:R3182C4"
>
> When I resize the range in my code I use this code
> CompanyXrefRange.Resize(CompanyData.Rows.Count + 1, CompanyData.Columns.Count)
> .Name = "CompanyXrefRange"
>
> Can I combine the two concept above so when This Workbook is executed it will
> coount the rows and the columns to create the appropriate size of the Range
>
> Thanks
>
> --
> Message posted via http://www.officekb.com
>
>

 
Reply With Quote
 
Fredriksson via OfficeKB.com
Guest
Posts: n/a
 
      3rd Apr 2007
How would I delare CompanyData if I do not have a range define? How would
the program know Which Worksheet Columns and Rows to use.

Bob Phillips wrote:
>Try this
>
> ActiveWorkbook.Cells(CompanyData.Rows.Count + 1,
>CompanyData.Columns.Count).Name="CompanyXrefRange"
>
>> Using This Workbook module, I need to set up Name Ranges everytime the
>> Work

>[quoted text clipped - 16 lines]
>>
>> Thanks


--
Message posted via http://www.officekb.com

 
Reply With Quote
 
Fredriksson via OfficeKB.com
Guest
Posts: n/a
 
      3rd Apr 2007
This is getting close but how the code know what name to call the offset
Barb Reinhardt wrote:
>When you set up the named range you could do something like this:
>
>=offset(Sheet1!$A$1,0,0,counta($A:$A),counta($1:$1))
>
>It will dynamically expand and contract as needed. Let me know if that's
>what you need.
>
>> Using This Workbook module, I need to set up Name Ranges everytime the Work
>> Book is Open but the size of the range may change between each opening and

>[quoted text clipped - 12 lines]
>>
>> Thanks


--
Message posted via http://www.officekb.com

 
Reply With Quote
 
Fredriksson via OfficeKB.com
Guest
Posts: n/a
 
      3rd Apr 2007
ActiveWorkbook.Names.Add Name:="CompanyXrefRange", RefersToR1C1:= _
"=offset(XrefProperty!$A$1,0,0,counta($A:$A),counta($1:$1))"

I tried this but it did not work

Barb Reinhardt wrote:
>When you set up the named range you could do something like this:
>
>=offset(Sheet1!$A$1,0,0,counta($A:$A),counta($1:$1))
>
>It will dynamically expand and contract as needed. Let me know if that's
>what you need.
>
>> Using This Workbook module, I need to set up Name Ranges everytime the Work
>> Book is Open but the size of the range may change between each opening and

>[quoted text clipped - 12 lines]
>>
>> Thanks


--
Message posted via http://www.officekb.com

 
Reply With Quote
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      3rd Apr 2007
Use INSERT -> NAME -> DEFINE

Enter CompanyXrefRange for your RangeName
Enter =offset ... for your "Refers To"

Then look at the Sheet and type CTRL G and type in the RangeName. If the
offset equation needs to be modified for length, height, begin ... come back
and let me know the problem and I can assist.


"Fredriksson via OfficeKB.com" wrote:

> ActiveWorkbook.Names.Add Name:="CompanyXrefRange", RefersToR1C1:= _
> "=offset(XrefProperty!$A$1,0,0,counta($A:$A),counta($1:$1))"
>
> I tried this but it did not work
>
> Barb Reinhardt wrote:
> >When you set up the named range you could do something like this:
> >
> >=offset(Sheet1!$A$1,0,0,counta($A:$A),counta($1:$1))
> >
> >It will dynamically expand and contract as needed. Let me know if that's
> >what you need.
> >
> >> Using This Workbook module, I need to set up Name Ranges everytime the Work
> >> Book is Open but the size of the range may change between each opening and

> >[quoted text clipped - 12 lines]
> >>
> >> Thanks

>
> --
> Message posted via http://www.officekb.com
>
>

 
Reply With Quote
 
Fredriksson via OfficeKB.com
Guest
Posts: n/a
 
      4th Apr 2007
Thanks this iworking better

Barb Reinhardt wrote:
>Use INSERT -> NAME -> DEFINE
>
>Enter CompanyXrefRange for your RangeName
>Enter =offset ... for your "Refers To"
>
>Then look at the Sheet and type CTRL G and type in the RangeName. If the
>offset equation needs to be modified for length, height, begin ... come back
>and let me know the problem and I can assist.
>
>> ActiveWorkbook.Names.Add Name:="CompanyXrefRange", RefersToR1C1:= _
>> "=offset(XrefProperty!$A$1,0,0,counta($A:$A),counta($1:$1))"

>[quoted text clipped - 13 lines]
>> >>
>> >> Thanks


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200704/1

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic range based on criteria, within a dynamic range, passed to a function rajansood@hotmail.com Microsoft Excel Programming 5 9th Oct 2007 10:13 PM
creating a dynamic range based on criteria, within a dynamic range, and passing it to a function rajansood@hotmail.com Microsoft Excel Programming 0 9th Oct 2007 05:22 PM
Dynamic Range with unused formula messing up x axis on dynamic graph cabybake@yahoo.com Microsoft Excel Charting 2 2nd Feb 2006 08:02 PM
Dynamic Range with unused formula messing up x axis on dynamic graph cabybake Microsoft Excel Discussion 6 25th Jan 2006 06:40 PM
Excel 2000 VBA - Set Print Range in dynamic range sub_pop Microsoft Excel Programming 2 27th Jul 2004 08:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 PM.