LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Jonathan Cooper
 
Posts: n/a
Default dynamic range name

I'm looking for a HINT. I want to figure this out myself, but I'm stuck.

I wan't to start using dynamic range names for my pivot table data. But I
also don't want to have to type the formula in, over and over, because I
create them frequently.

I've created the following macro. I'm planning for the scenario, where I
have more than one database in a particular file. maybe sheet 1 has the
first data, and sheet two has different data. My thought is to run this
macro on sheet one and have it default to the name DataBase1. Then when I'm
ready, I run the macro on sheet 2 and it would autmatically create a name of
DataBase2. However, each time I run the macro, it defaults to DataBase1.
This is where I need the first hint.

Sub Macro1()
'
' Create a dynamic range name for my data, to be used in a pivot table.
' Macro recorded 4/5/2006 by Cooper
'

'
Dim DataName As String
On Error Resume Next

DataName = Application.InputBox("What do you want to call this range of
Data?", "Name your data", "Database" & cntr)
ActiveWorkbook.Names.Add Name:=DataName, RefersToR1C1:= _
"=OFFSET(Sheet1!R1C1,0,0,COUNTA(Sheet1!C1),COUNTA( Sheet1!R1))"
cntr = cntr + 1
End Sub

I also realize that the formula specifically references "Sheet1", and that
when I run this thing on "Sheet2", it's going to be pointing to the wrong
location. I plan to tackle that next.

thanks in advance.
 
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
Drawing data from specific columns of a dynamic range Darren Setting up and Configuration of Excel 3 March 3rd 06 06:53 AM
Crate group of date, with Dynamic Range in pivot table not working Tiya Excel Discussion (Misc queries) 3 March 1st 06 02:26 PM
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM
How to dynamically reference a dynamic named range paris3 Excel Worksheet Functions 4 June 24th 05 01:22 AM
Reference to a dynamic range Yossi Excel Discussion (Misc queries) 2 April 12th 05 12:57 PM


All times are GMT +1. The time now is 07:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"