# Get The Range Address Of A Dynamically Named Range That Refers To A Formula In VBA

Aug 10, 2008
I have a named range that expands and contracts based upon the amount of data that is in some column. Call it AllData_UsedRange.

I have another named range that actually refers to a range. Call it AllData.

Column A

Row2 56

Row3 44

Row4 65

AllData is a named range that refers to the range A2:A65536

AllData_UsedRange refers to A2:A4 by way of this formula.

=OFFSET(AllData,0,0,COUNTA(AllData))

How to I obtain an address of AllData_UsedRange in VBA code?

These do not work...

ThisWorkbook.Names("AllData_UsedRange").RefersToRange.Address

Evaluate(ThisWorkbook.Names("AllData_UsedRange"))

View 9 Replies
ADVERTISEMENT
Jan 13, 2010

My file has a code that refers to a dynamic named range. When I run the macro that range gets corrupted and I cannot figure it out why. before the macro the named range refers to:

=OFFSET(Manager!$A$1,0,0,MATCH("*",Manager!$A:$A,-1),3)

and right after I run the macro it turns to:

=OFFSET(Manager!#REF!,0,0,MATCH("*",Manager!$A:$A,-1),3)

View 2 Replies
View Related
Jun 15, 2007

is there a way to have the same named range cover a range of cells regardless of which sheet you are on? They seem to want to default to the page you are on. I want to make some VBA subroutines that will go over each sheet, and perform the same functions on each sheet. All sheets have the same format, but different data. I guess worst case scenario I can just break down and use multiple workbooks, but this seems a little less desirable. Should I be dividing this into seperate posts?

View 3 Replies
View Related
Aug 25, 2006

I know that I can return the value of a defined name range, the address, and even the value of the define name, but if you are given a range address, how do you find its corresponding defined name in code?

View 4 Replies
View Related
Apr 19, 2013

I have a challenge I'm trying to surmount. I have an excel sheet in which I want to be able to select Zone codes from a drop down, click on a link "search" which takes me to a place in the document that has been named according to the Zone code i pick in the drop-down. I want to achieve this using only formulas as i'm distributing the file to a wide audience who are not versed enough with computers to know how to enable macros.

View 3 Replies
View Related
Feb 20, 2008

how to get the value of a cell by its name. For example, i give cell B2 Name "Hello" and value "2". how to use vba to get the value of 2 using its name 'Hello', but not the cell 'B2'. Somethings people delete and add rows or columns and using range may lost the right value.

View 2 Replies
View Related
Dec 22, 2006

I'm having a 'mental block' day. I have a Named Ranges in a spreadsheet (Office XP). The range is defined as =OFFSET( ' Stock List'!$K$1,0,0, COUNTA('Stock List'!$F:$F),4)

i.e. starts at K1, is 4 cols wide and as deep as there are occupied cells in col F. (as I understand it). I want to treat this as an array in VBA and use 'x' and 'y' as indexes into the array. I want to either get the value from a single cell, or set the value in a single cell, which contain a string. I know its not correct but I have the formulae as follows, and for the life of me I cant figure out what the correct formula is -duhh!!

Dim x As Integer, y As Integer, z As String

x=3 'dummy test code

y=2

Range("MakerExtractArea").Offset(x, y).Value = "dummy"

z= Range("MakerExtractArea").Offset(1, 0).Value

View 7 Replies
View Related
Sep 8, 2006

I am trying to create a graph for a range of data that updates monthly (adding an extra month each time). I wanted the graph source data to update automatically each time the data is refreshed so used an OFFSET formula to identify a named range. I then point the graph to the named range as the source data.

When I enter the range as the source data the graph picks it up. However, when I re-enter the source data option on the graph it has converted the named range into a cell written range (ie. replaces "=QUALITY" with "='Front page'!$B$7:$J$10" - which therefore will not update when the range increases.

View 4 Replies
View Related
Mar 22, 2012

How I change the code below so that the ."AddItem" refers to a range within Sheet1?

For example .AddItem Worksheets("Sheet1").Range("O2:O20")

Code:

With ListBox1

.AddItem "January"

.AddItem "February"

.AddItem "March"

View 2 Replies
View Related
Aug 16, 2014

Let's say you have a named range, Rng1, which consists of cells A1 & A2. In vba how would you report back what, if any, named range the following cells resides:

Code] .....

here are multiple named ranges so using intersect is not feasible. Essentially, through code, I will be given a range and I need to determine if that range if part of a named range.

View 5 Replies
View Related
Mar 1, 2009

I have a named range, called 'event' relating to cells a2-a200, I have a named cell, 'eventcounter'. I was hoping that I would be able to use the named cell eventcounter in formulae on the cells in the event range rather than having to use the cell address. So instead of having a formula that was something like this, =if(a3= etc etc.

I could refer to the range event and eventcounter. Eventcouter gets its value simply by counting the number of non blank cells in the event range, so consequently - I can only figure out how to address the last entry in the event range in the manner that i wish.

View 2 Replies
View Related
Mar 21, 2014

I'm trying to design an if statement that refers to a range of cells on a calculation sheet to perform one calculation on TRUE; another on FALSE

=IF(A22='Calculation Sheet'!A27:A36,B22*100/16,B22*100/8)

When I view the formula in Function Arguments window, Value_if_true = 1043.75 & Value_if_false = 2087.5 <- these are correct

IF Func Arg.jpg

When I view the cell in the spreadsheet, system displays #VALUE!

When I view Evaluate Formula window, it seems Excel doesn't like the text.

IF Form Eval.jpg

View 5 Replies
View Related
Aug 23, 2007

I have several workshts in a file with a summary worksht. I have named ranges of data on each by salesperson. How can I use a formula to get the named range from each tab to show up on the summary sheet. I tried (=Smith!AugustSales), which is the - sheet name Smith and the named range AugustSales, but I get an error.

View 9 Replies
View Related
Dec 30, 2007

Lets say that B2:B100 contains a list of numbers, and it is named RANGE1

Is it possible to make by using any formula -another named range (RANGE2) based on the first but contains every 2nd or third cell of the original range.

The solution must avoid creating another column - it has to be one formula that can be used as new named range in any application (chart series...etc.)

View 9 Replies
View Related
Jul 19, 2013

I'm trying to make my named ranges remember the values of the last active cells used within another named range. The purpose of this is to make my charts dynamically change dependant on two criteria selected. My spreadsheet currently updates itself as and when I change the active cell within a single named range, dynamically changing the chart data by using Lookup based on the active cells value. However I want to get away from having several charts showing, I would like to have a single chart which dynamically changes based on a second selection. So the first selection is for a department (Facility) which changes the chart data relevant to that department, the second selection is to dynamically change the chart shown for the pre selected department.

Picture2.jpg

Using the following code when updating just one criteria with several charts

VB:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Application.Intersect(ActiveCell, [MeasureType]) Is Nothing Then

[valMeasurePicked] = ActiveCell.Value [code].....

which works fine but I'm not sure how to add a second selection criteria because my code uses Activecell. I thought that the VBA needed to set the last used value of a range as a variable and therefore allow the second criteria to be selected but am not sure how to put it into practice.

View 2 Replies
View Related
Aug 19, 2006

I have two spreadsheets. The sourse spreadsheet already has many named ranges which i would like to use for the main spreadsheet to pick up its information. Is there an easy way when using vlookup or the like to name the range in the other spreadsheet?

View 5 Replies
View Related
Aug 31, 2007

I want to be able to do is to have a text value in a cell which will be the same as a named range and can be called from a formula in another cell. For example, I have three named ranges: JAN, FEB and MAR. Instead of having a formula which might read: =VLOOKUP("bill", JAN, 1, 1)

I would like to have in cell A1 the text value "JAN" so that the formula can read:

=VLOOKUP("bill", A1, 1, 1)

Then I can change which named range is used in the formula but changing the value in cell A1. When I try to do this, the formula just looks up the value as if cell A1 was the range rather than taking the value from A1 as the named range.

View 2 Replies
View Related
May 3, 2006

is it possible to concatenate in such a way that formatting is retained? For example, my =CONCATENATE formula refers to a cell containing 0.065, but which is formatted as a % so that the cell shows 6.5%. Concatenating that with text, however, produces "0.065 [text]"

View 4 Replies
View Related
Jan 11, 2010

I know I've asked before but I can neither find my previous question or the answer.

So, once again.... is it possible to refer to a named range in a CSE array formula?

I know how I would type a formula that way -- but I would be happy to see an example.

Most importantly, will it always work? Or are there pitfalls and dangers?

View 3 Replies
View Related
Jun 3, 2014

Trying to get this short piece of code to work. I'm trying to show the formula in the cell not just return the result.

[Code] ......

Why this isn't working ?

View 5 Replies
View Related
Jul 14, 2012

I have as the two logical operators for an IF function the following COUNTA calculation which checks how many blanks are in the range GrdMtx7 and subtracts this from the value in E5 and adds the suffix "Module(s)".

Code:

(E5-COUNTA(GrdMtx7)-1)&" Module(s)",(E5-COUNTA(GrdMtx7)&" Module(s)")))

GrdMtx7 is a non-contiguous range consisting of the following cell references on a second sheet:

Code:

='Mod Schedule'!$E$7,'Mod Schedule'!$H$7,'Mod Schedule'!$K$7,'Mod Schedule'!$N$7,'Mod Schedule'!$Q$7,'Mod Schedule'!$T$7,'Mod Schedule'!$W$7,'Mod Schedule'!$Z$7,'Mod Schedule'!$AC$7,'Mod Schedule'!$AC$7,'Mod Schedule'!$AF$7,'Mod Schedule'!$AI$7,'Mod Schedule'!$AL$7,'Mod Schedule'!$AO$7,'Mod Schedule'!$AR$7,'Mod Schedule'!$AU$7,'Mod Schedule'!$AX$7

I need for the formula of the IF function to copy down so that it refers to F5, G5, H5, I5...etc.

I also need for the non-contiguous named range GrdMtx7 to refer to the same non-contiguous range shifted down one row intact for the COUNTA function to operate on the next row down, such that COUNTA is checking for blanks in the range:

Code:

='Mod Schedule'!$E$8,'Mod Schedule'!$H$8,'Mod Schedule'!$K$8,'Mod Schedule'!$N$8,'Mod Schedule'!$Q$8,'Mod Schedule'!$T$8,'Mod Schedule'!$W$8,'Mod Schedule'!$Z$8,'Mod Schedule'!$AC$8,'Mod Schedule'!$AC$8,'Mod Schedule'!$AF$8,'Mod Schedule'!$AI$8,'Mod Schedule'!$AL$8,'Mod Schedule'!$AO$8,'Mod Schedule'!$AR$8,'Mod Schedule'!$AU$8,'Mod Schedule'!$AX$8

I can't get got to work at all using OFFSET and would rather not create dozens or hundreds of named ranges incrementing one at a time - is there a way to achieve this, preferably with a formula, but vba if absolutely necessary.

My best effort doesn't work:

Code:

(E6-COUNTA(OFFSET(GrdMtx7,1,))-1)&" Module(s)",(E6-COUNTA(OFFSET(GrdMtx7,1,)))&" Module(s)")

View 2 Replies
View Related
Apr 2, 2009

I have several named ranges with 4 column each. The named ranges have all the same names but with the tow last digits ranging from 00 to 50 by increments of 5 (ie 00, 05, 10, 15 etc.). The 4 columns for each of the named ranges have the following headings; 10, 100, 50 ,70. I have two cells with drop down lists with the list of the suffixes of the named ranges in cell e5 (ie 00, 05, 10, etc) and in g5 a drop down list with the 4 headings for the columns (10, 100, 50, 70)

I want to refer to these 2 values so that in column B, I can get the values of the column chosen for the given named range. For example, the column "100" for the named range THRESHOLD_10. In cell C1, I entered the following formula ="THRESHOLD_"& E5 which gives me the named range name. I entered the following function in the first cell of column B = index(C1,2,G5) but get a #REF! answer. If I write the following formula =index(THRESHOLD_10,2,G5) I get the right value.

how to get about it, and indirect(C1), but still gets a #REF! message. When I evaluate the formula, the named range appears with quotes "" which might be the reason that it cannot work. I am nearly there...but for the syntax and cannot get that working!

View 3 Replies
View Related
May 19, 2009

I have a named range which refers to: =MATCH(LARGE($G$5:$G$68,ROW(G5)-4),G$5:G$68,0)+4. It is supposed to find the largest figure in the adjacent column, list its row in cell H5, then the second largest for cell H6 and so on until the end of the data. The data in column G is dynamic and some cells will contain "0" with certain sections of data thus why I need a formula and cannot just use sort each time.

My problem is that when I use the formula as a named range I get "#N/A" and when I evaluate the formula I will get the answer but in array brackets (e.g.{17}) before the final step turns it to "#N/A". The formula will work fine if inputted directly into the cell but as the same formula will be used over three columns and numerous rows I would much prefer to use a named range.

View 8 Replies
View Related
Apr 28, 2009

Can you use Row & Column numbers in a Formula the way you can in VBA?

I want to do the same as Range(Cells(5,2)) in VBA EXCEPT in a Formula

because I want to use named ranges for the Row & column entries. (And I don't want to have to run a macro every time a change is made. The spreadsheet is huge enough already. It's slow on my machine & I have the biggets baddest PC in the company!)

Using Formulas only, (not VBA) I would like to create a Dynamic Named Range, LastUsedRow, which is the ROW NUMBER of the Last Used Cell in Column C

(it would = 470)

Also I have an existing Named Range HeaderRowNum (it = 16)

Currently I have a LOT of formulas like:

=SUMPRODUCT(($E17:$E470)*(--(CO17:CO470>0)))

problem is any new data must be added between Rows 17 & 470

So I would like to create dynamic new forumlas to read like:

SUMPRODUCT( (Cells(HeaderRowNum+1,5) : (LastUsed Row,5)) * (--(Cells(HeaderRowNum+1,93) : (LastUsed Row,93))>0) )...............

View 5 Replies
View Related
Oct 20, 2009

I have the following formula which works fine in this form:

View 4 Replies
View Related
Jul 21, 2006

I am trying to put a SUMIF formula at the bottom of the data. Doing it manually is fine, but I want some vba to automate it, and my vba doesnt work.

Sub balance()

'adds journal line so journal balances in each month

Dim Rga As Range

Dim Rgb As Range

Dim Rgc As Range

Dim Rgd As Range

Dim Rge As Range

Dim Rgf As Range

This code just inserts text into the formula, rather than the range of cells.

View 6 Replies
View Related
Sep 13, 2006

how to pass a cell content into a formula as a named range? For instance, I have 3 named range (Budget, Actual, Forecast) and I use the named range in vlookup formulas. But instead of using the named range in the formula directly, I want to refer to a cell where I can type in which named range I want to use. Can this be done? I am attaching a sample spreadsheet to clarify what I mean.

View 6 Replies
View Related
Aug 13, 2008

I have a problem creating a circular reference with dynamic ranges. I have searched already but can't find the specifc problem. I have a spreadsheet where I use vba code to insert extra columns. Within the worksheet there are sum calculations at the end of each row. When I add a new column within the table I would like the sum calculation to expand to account for this extra column.

Now, I thought that dynamic ranges would be the way to go but the only way I can see to do it creates a circular reference as the CountA function trys to count the cell with the sum function in it.

View 2 Replies
View Related
Dec 3, 2013

I have a Choose function that is used to determine which range I need. e.g. =Choose(Choice,Cell,Cell,...).

In each corresponding "Choice" cell is a typed range. e.g. $B$33:$L$70

I'm looking for a way to be able to use this typed range as the range for some chart data.

View 2 Replies
View Related
Jan 18, 2013

Basically on a summary page, on sheet 1 say I have a formula which picks up the unit cost (I have this as an array across 5 years)

What I then want to do is multiply this by a volume driver. I have a list of these drivers on a seperate page, so for convenience lets say DRIVER_01,DRIVER_02 etc. These are also 5 years arrays.

So what I want to do it be able to select which driver I want to use for volume on the summary, from a drop down box I have set up, and then the formula pick up that named range, and not just recognise it as a text cell.

I need the ability to change the driver in the future, hence the drop down box. I can also get the unit array part to work fine, I'm just struggling to get this driver array to work..............

View 2 Replies
View Related