Using Variables In Range References
Jun 5, 2009
I am doing some work in which I need a very flexible tool. I will be doing regression analysis on thousands of funds at a time. I need to define the range for each fund by a count function that counts the number of monthly returns that are posted. The code I have so far is below (I underlined where the references use variables):
View 3 Replies
ADVERTISEMENT
Dec 8, 2008
I'm having problems with the MATCH function. If I use =MATCH(A2,'c:myfile.xlsx'!MyRange,0), it works. A2 is the value that I want to look up. 'c:myfile.xlsx'!MyRange is the full path of a range in an another XLSX.
However, if I assign the file name to a cell and try: =MATCH(A2,A3,0). where A3 has the exact same path as the line that work, Excel returns #N/A. I also tried a match on a range in the same tab of the same spreadsheet, and it didn't work. Is it possible to do what I'm trying to do? The file location of the external XLSX is going to change, and I wish I could just update one cell rather than every single cell that contains a MATCH.
View 5 Replies
View Related
Jul 7, 2007
I have inherited an Excel workbook in which the formlas all contain cell names (and there are thousands of names in this book). I need to find a way to change from using cell names in a formula back to a standard absolute cell reference but have no idea how to do this?
View 9 Replies
View Related
Jan 17, 2005
I have a spreadsheet with very long formulas that reference a whole lot of variables in the same column. I tried naming the cells so that writing of the formula is easier to do. However, I need to copy the column across for other entities of varying nature, and these copied cells refer to the same named cell. Can I name a cell and copy it sideways so that it retains some sort of name with allusion to the column that it is in?
Andrew van Gruting"
I have tried copying a formula with a named range and, as expected, it maintains an absolute reference. Is there a way that he might be able to copy but drop the absolute reference and copy with relative references. Can I place something in front - the equivalent to the $ sign, but rather a relative sign.
View 6 Replies
View Related
Jun 5, 2009
I have a workbook with a single worksheet. The worksheet includes some named ranges, which are used in a dynamic chart (so that when I add data, the chart updates).
I want to duplicate worksheet#1 so that I can have worksheets 2, 3, 4 etc.
Thus I can paste new data in the new worksheets, and have all my calculations done.
Naturally, the only probelm is the graph. It is using the named ranges from worksheet #1.
Is there a solution, so that I don't have to re-create my graphs on each worksheet? (each worksheet has varying numbers of rows, AND, I will be updating each worksheet with new data from time to time, thus the need for a dynamic chart)
View 4 Replies
View Related
Jun 29, 2012
$TC$2:$WX$3
is an indirect range that resides in cell B15. It is constantly changing and the expectation is that the X_Y plot would adjust accordingly. It represents the data range of the chart. The chart does not carry with it any title.
So how do I approach this without using vba? As always any input is highly valued.
View 2 Replies
View Related
Dec 8, 2008
how to lock ALL cell references in the formulas within a range in one go, rather than ahving to go to each and every cell and lock them manually?
I have a table with 966 cells all with just one cell reference like this: .....
View 9 Replies
View Related
May 12, 2006
Could someone show me an alternate way of using/writing this code instead of using RC references to the Sheet1. I am trying to select ranges that dynamically change according to the range of data in the next column. This is the code I have but it is static in the range it chooses.
=LINEST(Sheet1!RC[1]:R[61]C[1],Sheet1!RC:R[61]C^{1,2,3,4,5,6})
View 4 Replies
View Related
Apr 30, 2007
I'm trying to combine 2 variable column refs and 2 fixed numbers to select a range in VBA, but I can't get the correct syntax re the number of inverted commas.
Range("" & strFrom & "4"":" & strTo & "7""").Select
(strFrom and strTo are the column variables, already defined)
I've tried every combination (except the right one!) for over an hour and just cannot get this to work.
If someone can also explain the logic around the number/placement of inverted commas it would be much appreciated - since they're all straight, I'm never sure whether I'm closing a set or opening a new set.
View 3 Replies
View Related
Oct 22, 2009
I have a number of statements within the Sheet Event Code (Excel 2007). Three times lately I have added a column and had to go back into the code and find all of the references that needed changing to reflect the new column.
I have been working on this for a couple of days and even tried EE, but to no success.
I have read that Defined Names / Constants should be used as often as possible, but even trying that, the VBA code errors out or "hangs up". Even within Bill Jalen's book (VBA and Macros 2007), there is nothing that addresses this, especially using Intersect.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
On Error GoTo mEnd
Set rng = Sheets("Log").[F14:F10000]
If Not Intersect(rng, Target) Is Nothing Then
If Target = "" Then
With Sheets("Log")
View 9 Replies
View Related
Feb 10, 2014
I set up formulas to count text characters in a range of cells. I'm tracking attendance and payments for a small yoga studio.
All I need to do is count "Y"s for prepaid attendance and "DI"s for drop-ins. I have the formulas working but they are absolute so inserting a row will break my sheet.
=COUNTIF(E14:Z14,"*Y*")
=COUNTIF(E11:Z11,"*DI*")
View 1 Replies
View Related
Nov 25, 2007
It is suppose to be that if the employee is "FT" and has worked >=4 years the return is 15. But if the employee is FT and has worked 2 years but less than 4 years then it is suppose to return 10 (these are days off) Or if the employee is FT and has worked 1 year, but less than 2 then it should return 5 days off. And all the others in the column get no days off.
I have tried to do it with structured references and with cell references I get a column of zeros!
View 9 Replies
View Related
Aug 6, 2013
I inherited a Profit & Loss (P&L) template from a colleague. She developed it on Excel 2013 and I'm on Excel 2010, but it's not clear that is the issue here (tho, never say never).
The spreadsheet was set up for quarters and I've expanded it (by copy and paste) to 12 months. It has the typical tables: sales revenues, cost of goods, admin exp, etc. Each table has a number (varies from table to table) of rows with a subtotal in the bottom row of each table. There is also a label row above all the tables (this now has the month labels).
The problem: The subtotal (bottom) row of a table uses the formula "=SUBTOTAL (109, ref1)". In the original spreadsheet, ref1= "QTR1" (or QTR2, QTR3, etc.). I'd like to change that to be MONTH1, MONTH2.... However, when I enter MONTH1 or MONTH2, etc. for ref1, I get a formula error. Which I suspect is expected.
What I noticed is that if I highlight ref1 in the subtotal cell formula and then select the cells I want included in the subtotal, the first selected cell shows a "B8". With 2 cells, it shows "B8:B9". Good so far. However, when I get to the last cell before the subtotal row, ref1 changes to "[QTR1]", so the final subtotal formula shows "=SUBTOTAL (109, [QTR1])".
I've tried to change QTR1 to MONTH1, but get an error. I used Name Manager, but QTR1 doesn't show up on the list (However, the tables are named and seem to reference the columns correctly). If I do a "Define Name", the window pops up w/the name entry empty and the "Refers To" containing "=tblName[QTR1]" (tblName is the name given to the specific table (revenue, cost of goods, etc.) and does show up under Name Manager).
I tried an experiment and in the revenue table I deleted (move left) the cells (up to but not including the subtotal cell) under MONTH1, and then inserted (move right) a new set of cells. Now the "Refers To" shows "=tblSalesRevenue[Column7]".
So, apparently, Excel can assign some kind of label to a set of cells. My question is, how do I (if I can) change that label, or name, so that the column of cells I want to use for my subtotal formula will work (MONTH1, MONTH2, etc.). It's not clear that Define Name or Name Manager is what I should use. I looked at the original spreadsheet and there are no Name Manager listings for QTR1, QTR2, etc.
Additional Note: I forgot to mention that this isn't a show stopper, just a nuisance. If I use normal cell references (i.e. B8:B11, etc.) the spreadsheet works fine and as expected. This is just one of those "nits" that I'd like to understand so that I can make the spreadsheet programming more "readable".
View 4 Replies
View Related
Mar 28, 2014
My goal is that the formula in this named range references the prior 12 months. This does reference a twelve month range in my workbook, but not the prior 12 months based on this month being MARCH.
DATES =INDIRECT("sheet1!A"&MONTH(TODAY())+1&":A"&MONTH(TODAY())+12)
View 1 Replies
View Related
Dec 20, 2006
I would like to rotate a Line Chart 90 degrees. I tried using an XY scatter chart but my Y-axis would be time values which are somewhat random but increasing. I would like to keep the spacing between plot points consistent (Y-axis spacing). I could simply use a number list for my Y-values to get consistent spacing but then I lose the time information. I don’t necessarily need the time value on the Y-axis if I could get the information to display when mousing over the plot point. Any ideas on how I could accomplish this?
View 6 Replies
View Related
Feb 5, 2008
I have a large workbook with LOTS of large formulas. However they dont contain $ characters before the ranges as I haven't needed to manipulate them til now. Now I am changing the sheet and I cant seem to move or copy these cells without the ranges whithin the formulas changing! Is there a way to do this? If not is there a way in VBA that I can check through selected cellls and enter a $ before all the ranges?
View 2 Replies
View Related
May 20, 2013
This works
ws2.Range("C5").Formula = "=sum(D5:ZZ5)"
guide me on the syntax when the final column reference is a variable
ws2.Range("C5").Formula = "=sum(D5:" & Cells(5, l_LastCol) & ")"
doesn't work
View 3 Replies
View Related
Jul 20, 2006
eg say you call (ie insert a range name) cell A1 "firstcell", B1 "secondcell", then A2 "divisor1" and B2 "divisor2". if you put a formula in A3 which is "=A1/A2", how do you copy and paste this formula into B3 but getting the formula to reference B1/B2 rather than firstcell/divisor1, as it does by default?
View 2 Replies
View Related
Mar 2, 2009
I am using the dsum formula to sum some values...the formula in B2 is:
=DSUM(BaseSistemasFebrero,"vlfinf",OFFSET('Planes Entidades'!B$1,0,0,COUNTA('Planes Entidades'!B$1:B$49),1))
The Planes Entidades sheet the data is layed out like this: ....
View 9 Replies
View Related
Aug 23, 2009
I used a macro to get the following code, but would like to do this with VBA code where I use variables and numbers instead of the
macro's ("I568:J568") notation. Thus I would have something like (lRow, 9) : (lRow, 10) or whatever the correct notation is. Basically I'm trying to copy and paste formulas from one row to the next.
View 4 Replies
View Related
Dec 30, 2013
I am trying to sum the range of column B (Being the found match in column A offset 1) to the relevant column set by the variable intcolumn (integer value of the column matching the criteria (in this case column 25)
Code:
rngMember.Offset(0, 13) = Application.Sum(rngTradeMember.Offset(0, 1) & ":" & rngTradeMember.Offset(0, intColumn))
The sum does not fail but returns an incorrect figure.
What I am hoping to see is a sum of the following
result sheet offset (0,13) = sum of (column B to the column Y)
View 7 Replies
View Related
Jan 3, 2014
Is there a way to unfix multiple cell references from formulas in a range of cells at once?
View 2 Replies
View Related
Sep 9, 2013
I am try to get the following VBA macro to work; however, I keep getting hung up on errors regarding the formula I am trying to input. It is getting hung up on the apostrophes and dollar signs. I am fairly new to VBA so I am lost when it come to converting my sheet formulas to VBA.
Code:
With ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks)
.Formula = "=RAND()*0+VLOOKUP(INDIRECT(ADDRESS(1,COLUMN(),3),TRUE),INDIRECT("'"&TEXT(INDIRECT("$A"&ROW(),TRUE),"DD-MMM-YYYY")&" Inv'!"&"$J:$K",TRUE),2,FALSE)"
.Value = .Value
End With
View 3 Replies
View Related
Mar 16, 2008
Is there a way to absolute reference multiple cells at one time?
View 5 Replies
View Related
Jun 18, 2009
I'm trying to create a simple checkbook application for a friend. I've gotten pretty much everything I want figured out except for two functions, which are basically the same thing. I'm trying to find the sum of all deposits and of all withdrawals based on two entered dates.
Basically, they enter the dates, and the formula finds the dates, then sums all the deposits/withdrawals between them. I attached the workbook with some sample data in case I wasn't really clear.
View 2 Replies
View Related
Aug 3, 2012
I'm trying to use a range(Cells1),(Cells2) all working fine, but now I'm trying to use variables for the Row selection. selection.row as one of the variables, but keep on getting a error.
Code:
Sub Clear_Time()
Dim Rng As Range
Dim pointer As Integer
pointer = Worksheets("Summary").Range("Z1").Value
Worksheets("SubPanel").Range((Cells(10, pointer)), (Cells(52, pointer))).Find(What:="").Activate
[code].....
View 3 Replies
View Related
Jun 23, 2008
How would I select a range using variables? For example, say I wanted to say
myRange = Sheets(1).Range("A1:A100"),
but the column was variable. How would I do this if the column number was stored in a variable?
View 9 Replies
View Related
Jun 20, 2007
How to decide the two range object variant represent the same range? Plz check the following code, How to decide Rng4 and Rng5 is or not the same range?
Sub IsTheSameRange()
With ActiveSheet
LastRow = .Cells(65536, "B").End(xlUp).Row
Set Rng1 = .Range(.Cells(3, "K"), .Cells(LastRow, "K"))
Set Rng2 = .Range(.Cells(3, "AE"), .Cells(LastRow, "AE"))
Set Rng3 = .Range(.Cells(3, "BQ"), .Cells(LastRow, "BQ"))
Set Rng = Application.Union(Rng1, Rng2, Rng3)
Set Rng4 = Rng.SpecialCells(xlCellTypeFormulas, 23)
Set WhlRng = .Range("A3:DR" & LastRow)
Set Rng5 = WhlRng.SpecialCells(xlCellTypeFormulas, 23)
End With
End Sub
View 2 Replies
View Related
Jul 25, 2007
I'm trying to edit the predefined range in my macro that changes formulas to values.
My current macro looks like this:
Dim vCol As Variant
vCol = Application.InputBox("Select Column", Type:=2)
If vCol = False Or vCol = "" Then Exit Sub
Set UserRange = Range(vCol & "9:" & vCol & "35")
UserRange.Value = UserRange.Value
End Sub
I tried extending the range to include 48:53, but it doesn't work. I tried with this: Set UserRange = Range(vCol & "9:" & vCol & "35" & vCol & "48:" & vCol & "53")
View 6 Replies
View Related
May 23, 2008
I am trying to select rows using constants I have set-up so that I can then delete those rows. However I don't know how to set-up the row formula to accept the constants. So far I have something like
Dim a As Integer
Dim b As Integer
row(a:b).select
selection.delete
View 3 Replies
View Related