Passing Cell Content As Named Range In Formula
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
ADVERTISEMENT
Jun 6, 2014
I'm trying use a worksheet that contains named ranges as the source in a macro that will dynamically create pivot tables. The named range could be anything so it can't be hardcoded in the vba and has to come from the worksheet.
In my example, the string strI = "policy" which I know because the msgbox displays the string.
Code:
Dim strI As String
strI = Chr(34) & rngIn.Cells(1, 4).Value & Chr(34)
MsgBox strI
Application.Goto (strI)
But when I try to use strI in place of a hardcoded named range, it always gives me (Reference is not valid) error using the string variable in the following code but never when it's hardcoded in as "policy".
Code:
'This errors out
Application.Goto (strI)
'This works
Application.Goto ("policy")
View 2 Replies
View Related
Apr 8, 2008
I have a formula which is using named ranges-
=SUMPRODUCT(xxx-30,Ship_30)/SUM(Ship_30)
where Ship_30 name references the following-
='sheet 1'!$C$20:$C$38
The value of 20 is static, the value of 38 is dynamic. Each new time period adds another value (i.e. 39,40,41)
Having to edit each name range reference in the name manager is not acceptable since there is potentially over 30 to edit each month.
I would like to edit a cell which would have contained the value 38 (or C38) with a new value of 39 (or C39) so the range reference would be updated with the new value.
The goal would be to have a couple of rows with the following that could be edited with new values
View 9 Replies
View Related
Jun 10, 2013
I am trying to reference a named cell in a VLOOKUP formula as the table_array parameter.
The Named Cell "Input1" contains a table array definition of '[Test.xls]Sheet1'!$H$10:$J$100
When I try VLOOKUP($D3,Input1,3,0) - This returns #N/A as a result.
When I try VLOOKUP($D3,INDIRECT(Input1),3,0) - This returns a #REF error.
When I copy and past the contents of the Input1 named cell directly into the VLOOKUP formula, it works so I know the array reference is valid.
I am not proficient in VBA so I would like to accomplish this using basic Excel formulas if possible. how I can reference the named cell and have the cell value returned in the VLOOKUP function?
View 1 Replies
View Related
Jul 24, 2009
I wrote some code that toggles bewtweeen the word "Yes" and the function clearcontents.
What it does not do, is if you click on cell A1 and change it's contents and you click on the same cell again it does nothing. You need to click on another cell say A2 before you can go and change A1 again.
My code is as follows:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("Documents")) Is Nothing Then
On Error Resume Next
Application.EnableEvents = False
If IsEmpty(Target) Then
Target.Value = "Yes"
Else
Target.ClearContents
End If
Application.EnableEvents = True
On Error Goto 0
End If
End Sub
View 3 Replies
View Related
Dec 4, 2012
Passing Named Range into User Defined Function
MrExcel.com | Excel Resources | Excel Seminars | Excel Products mcm91201
Depending on time of day and computer I am sitting in front of I am using:
WinXP Pro SP2 with Excel 2003
Win7 Pro SP2 Excel 2007
Win7 Pro SP2 Excel 2010 on PC
Win7 Pro SP2 Excel 2010 on Mac Mini running Boot Camp
OSX Excel for Mac 2011
I have only tried this on Win7 Pro SP2 Excel 2007 but need it to work on all.
I enter the values 0, 1, 2 ... 89, 90 in cells A1 to A91
I select A1:A91 and name the range 'angle'
I create a user defined function:
Public function sindeg(value As Double) as Double
sindeg = sin(worksheetfunction.radians(value))
end
I want 'value' for the function in a cell to be replaced by the corresponding value in the same row (or column) in the named range 'angle'. For example (using commas as column separators). This works for Excel functions like sin, cos, radians, etc.
********** Worksheet Contents **********
A1 = 00, B1 = sin(radians(0)), C1 = sin(radians(A1)), D1 = sin(radians(angle)), E1 = sindeg(0), F1 = sindeg(A1), G1 = sindeg(angle)
A2 = 01, B2 = sin(radians(1)), C2 = sin(radians(A2)), D2 = sin(radians(angle)), E2 = sindeg(1), F2 = sindeg(A2), G2 = sindeg(angle)
A3 = 02, B3 = sin(radians(2)), C3 = sin(radians(A3)), D3 = sin(radians(angle)), E3 = sindeg(2), F3 = sindeg(A3), G3 = sindeg(angle)
......
A91 = 90, B91 = sin(radians(90)), C91 = sin(radians(A91)), D91 = sin(radians(angle)), E91 = sindeg(90), F91 = sindeg(A91), G91 = sindeg(angle)
Column A = input. Columns B, C, D, E and F all calculate the same value by row. Column G fails with a #VALUE. In row 1 the value of angle[1] = 0 therefore column D = C = B = sin(0) = 0. In row 2 angle[2] = 1 therefore B = C = D = 0.017452
How can I get the user defined function sindeg(value) in column G to accept the named range variable 'angle' like the Excel function radians(value) accepted it in column D?
This functionality should work horizontally as well as vertically. For example enter 'angle' A1 to CM1 then have sindeg(angle) filled from A2 to CM2. It should also work in the case where the named range 'angle' is a single cell.
I am sure that this is a simple variable type definition problem in my user defined function: should the input variable be defined as type Range? Or something more exotic?
The brute force approach is to have the function determine the input value by passing in the named range, working out dimensions, calculating offset between the cell the function is in and top (left) of named range, then counting down (right) to pick the correct value. However I cannot see adding all that code to EVERY function. Occam's Razor says there has to be an easier way since Excel built in functions seem to do it readily.
View 8 Replies
View Related
Oct 19, 2013
Not sure if possible but im trying to pass a range to a formula in excel from another cell.
[URL] .......
There is a sum formula in range B5 that sums the range (B9:13). I would like to have a formula in cell D5 that passes the new range in cells(D9:D13) to the formula in cell B5 and give the result in cell D5. Is this possible using Excel functions or would i need to create some sort of user defined function for this?
View 9 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
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
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
May 29, 2007
I am having a few problems with dynamic named range in excel 2000.
When adding new data to the range, excel extends the range correctly, but only copies some of the formula correctly. It does not copy the formula that references a cell from another line.
I am trying to create a excel spreadsheet and have a formula =e10-e9, which does not copy down.
View 10 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
Sep 4, 2007
I have read post re this question but have not been able to answer my problem. I get the error message 'Application defined or object defined error' when running the code below. I should indicate the range counter currently indicated about 6,200 rows that this code will work on and the individual range names in the list of 6,200 rows are spread over at least 20 worksheets.
The code appears to be running but after some time it stops on the line of code 'Range(Cells(i, 1).Value) = Cells(i, 2)'.
Sub PopulateWithImportData()
Dim counter As Integer
counter = Sheets("Imported Data").Range("Counter")
Application. ScreenUpdating = False
Application.Calculation = xlCalculationManual
Worksheets("imported data").Select
Range("a1").Select
i = 1
Do Until i = counter
Range(Cells(i, 1).Value) = Cells(i, 2)
i = i + 1
Loop
View 8 Replies
View Related
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
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
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
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
Feb 7, 2013
Column"A" on spreadsheet has list of unique Order Numbers. The orders are whole numbers with no letters or characters.
I want Columns B:J in each row to be a "named" range using the content in Col A as the range name.
So if A5 says "12345" I want b5:J5 to be named "12345".
View 7 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
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
Aug 6, 2013
I need method, using a button, that looks at a cell--say EO2, for example--, looks back on a master worksheet at a specified row and range for a match, then looks at the information from a specified range below the matching cell (The information in this column will either be blank or have an "X" in the cell), and then those rows that do not have an "X" will be hidden in the corresponding rows in the working worksheet. Therefore, if at any time the value in "EO2" ever changes, then it will automatically find a new match and repopulate and hide information as before. About 130 columns will have its own button so that a "query" can be made that depends on the information in a particular cell in that column.
The master worksheet now has matrix of 287 rows and 58 columns. Each row is for an operating procedure and each column shows a job code. An "X" in a coordinate cell for a column/row shows whether that job code is responsible for knowing that operating procedure. So, on the working sheet, an employee's primary job code is given underneath his or her name. When the button is pushed, all the operating procedures not required for a given person will be hidden and only the required ones will remain visible--grouped, if you will. Qualification dates will be easier to see now that the information is consolidated. Whenever someone transfers to a new position, a new code will be inputed on the working sheet. When the button is pushed, a new grouping will result. Any operating instructions that overlap will still have qualification dates, so that information will not need to be transcribed.
View 9 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
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
Apr 12, 2014
How to determine the correct formula for this requirement?
Assuming I have 2 individual excel files and an index excel file (in reality, there are more than hundreds of file). For index excel, once the user enter part number (eg. 1 or 2), the excel will look for the part number excel file and determine vlookup function.
The only problem I have here is I can not make the index file automatically add the part number shown on most left column into the required formula (replace the part number file section).
I tried use the indirect function but this require each file to be opened, which is not possible for actual use. I am looking for a function that can work in closed worksheet.
Attached files :
index.xlsx
1.xlsx
2.xlsx
View 2 Replies
View Related
Jul 7, 2014
I am currently trying to create a spreadsheet whereby if I enter certain text in a cell in Column A on worksheet 1 that correlates with text in a cell in Column A on Worksheet 2, then the description in Column B in Worksheet 2 is entered into Column B on worksheet 1.
For example, if worksheet 2 has the following:
Column A Column B
XXXX PRODUCT 1
YYYY PRODUCT 2
and I enter XXXX in column A on worksheet 1, I want Column B on worksheet 1 to automatically enter PRODUCT 1.
View 5 Replies
View Related
May 2, 2013
I'm trying to use the below formula to to return "true" when text in cell (M2) matches text in selected cells on same row (A2, E2, and G2)
However, all formulas I found online that serve this purpose deal with cell range only, not predetermined cells with exclusions.
Formula:
=IF(ISNUMBER(MATCH(M2,A2:G2,0),TRUE,FALSE) (This will match all cells between A2 and G2 against M2)
reforming this formula to match selected cells only in-between that range (A2, E2 and G2)?
View 7 Replies
View Related