Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Macro defining dynamic named ranges

At times I need to change the source data used in some formulas.
When this happens I would like to remove the source data sheet, called
RawData, and import a new sheet that contains current data.
I am trying to write a macro that would define named dynamic ranges on
RawData.

Im using this code I copied from some other post:
ThisWorkbook.Names.Add Name:="dAge",
RefersTo:="=OFFSET(RawData!$H$1,0,0,COUNTA(RawData !$H:$H),1)", Visible:=True

This line doesnt leave any trace in the Name list; InsertNamePastePaste
List does not show €śdAge€ť,
nor does a loop with €śDebug.Print crtName.Name, crtName.RefersTo,
crtName.Visible€ť

Even worse, this simpler one doesnt work either
ThisWorkbook.Names.Add Name:="dAge7", RefersTo:="=RawData!$H$1:$H$10",
Visible:=True

When I add the name with InsertNameDefine this works:
=OFFSET(RawData!$H$1,0,0,COUNTA(RawData!$H:$H),1)

I would appreciate any help with this syntax or other suggestions for
updating/defining dynamic ranges in VB.

Thank you.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Macro defining dynamic named ranges

I named a sheet "RawData", put some values in the top of Col-H and tried
your code to add names. All worked fine as expected.

Your code adds names to ThisWorkbook, ie the wb with the code. When you are
looking in the names dialog is ThisWorkbook the activeworkbook. If not
that'll be the reason for the confusion.

Regards,
Peter T

"adimar" wrote in message
...
At times I need to change the source data used in some formulas.
When this happens I would like to remove the source data sheet, called
RawData, and import a new sheet that contains current data.
I am trying to write a macro that would define named dynamic ranges on
RawData.

I'm using this code I copied from some other post:
ThisWorkbook.Names.Add Name:="dAge",
RefersTo:="=OFFSET(RawData!$H$1,0,0,COUNTA(RawData !$H:$H),1)",

Visible:=True

This line doesn't leave any trace in the Name list;

InsertNamePastePaste
List does not show "dAge",
nor does a loop with "Debug.Print crtName.Name, crtName.RefersTo,
crtName.Visible"

Even worse, this simpler one doesn't work either
ThisWorkbook.Names.Add Name:="dAge7", RefersTo:="=RawData!$H$1:$H$10",
Visible:=True

When I add the name with InsertNameDefine this works:
=OFFSET(RawData!$H$1,0,0,COUNTA(RawData!$H:$H),1)

I would appreciate any help with this syntax or other suggestions for
updating/defining dynamic ranges in VB.

Thank you.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Macro defining dynamic named ranges


Ooops... Good point. I'm running all macros from a single add-in book and
overlooked the meaning of ThisWorkbook.

Thank you for your help.


"Peter T" wrote:

I named a sheet "RawData", put some values in the top of Col-H and tried
your code to add names. All worked fine as expected.

Your code adds names to ThisWorkbook, ie the wb with the code. When you are
looking in the names dialog is ThisWorkbook the activeworkbook. If not
that'll be the reason for the confusion.

Regards,
Peter T

"adimar" wrote in message
...
At times I need to change the source data used in some formulas.
When this happens I would like to remove the source data sheet, called
RawData, and import a new sheet that contains current data.
I am trying to write a macro that would define named dynamic ranges on
RawData.

I'm using this code I copied from some other post:
ThisWorkbook.Names.Add Name:="dAge",
RefersTo:="=OFFSET(RawData!$H$1,0,0,COUNTA(RawData !$H:$H),1)",

Visible:=True

This line doesn't leave any trace in the Name list;

InsertNamePastePaste
List does not show "dAge",
nor does a loop with "Debug.Print crtName.Name, crtName.RefersTo,
crtName.Visible"

Even worse, this simpler one doesn't work either
ThisWorkbook.Names.Add Name:="dAge7", RefersTo:="=RawData!$H$1:$H$10",
Visible:=True

When I add the name with InsertNameDefine this works:
=OFFSET(RawData!$H$1,0,0,COUNTA(RawData!$H:$H),1)

I would appreciate any help with this syntax or other suggestions for
updating/defining dynamic ranges in VB.

Thank you.




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
Dynamic Named Ranges - is this possible? Code Numpty Excel Worksheet Functions 2 March 10th 10 04:01 PM
Defining an R1C1 style dynamic named range using vba [email protected] Excel Programming 3 August 21st 07 11:12 AM
Defining a named range for a dynamic result set Keith B.[_2_] Excel Programming 2 April 19th 06 10:26 PM
Dynamic Named Ranges clane Excel Discussion (Misc queries) 5 October 13th 05 03:26 PM
Defining Dynamic Ranges in Macro Prashant Garg Excel Programming 2 December 17th 04 01:47 AM


All times are GMT +1. The time now is 08:16 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"