Copy Relative Formula & Use Row Reference From Variable
Mar 5, 2008
I have the following code which Clears the content of a cell. The next thing I want to have happen is to have another cell equal a formula but make that formula relative to its place. The formula is the following =IF(ISERROR(VLOOKUP(F56,Routes_All,2,0)),0,VLOOKUP(F56,Routes_All,2,0))
I am not sure how to paste it where the row changes depending on where it is pasted. Here is the code that does not work...
Private Sub CommandButton1_Click()
Worksheets("2008 Log").Select
Dim cRow
cRow = ActiveCell.Row '
Cells(cRow, Range("Column_Type_Of_Ride").Column).ClearContents
Cells(cRow, Range("column_duration").Column).value = "=IF(ISERROR(VLOOKUP(F56,Routes_All,2,0)),0,VLOOKUP(F56,Routes_All,2,0))"
End Sub
As you can see, no matter where I paste it it will always refer to row "F". How can I have it refer to row "cRow"?
View 2 Replies
ADVERTISEMENT
May 26, 2008
In my data validation I have the following formula as the Source: =INDIRECT(SUBSTITUTE($F$2," ","_")). I want to be able to copy the cell and paste it into another cell and have the formula update to reference the new cell. Currently the validation is for cell G2 and references F2. I want to be able to copy G2 and paste it in G3-G6 having the formula update so it refrences F3-F6.
View 3 Replies
View Related
Sep 30, 2013
I have a list of University courses listed in Sheet1. Column A contains a unique course code. If there is a problem with a course, a second worksheet (called Anomalies) contains the same unique course code with description of the problem(s).
What I'm trying to do is: in Sheet 1, create a hyperlink to the relative cell in Sheet 2 that shows the course code and description. I've gotten close, but am not sure how I can do this without having to update two formulas. In short, I can't find a way to combine the two formulas.
What I've done is the following: in Sheet 1, column B, created a HYPERLINK formula, thus: =HYPERLINK("#"&CELL("address",INDIRECT(C54)),A54)
Column C contains a formula to lookup the relative position in the Anomalies worksheet, which can be referenced back to the HYPERLINK formula, thus:
=("Anomalies!A"&MATCH(A54,Anomalies!A:A,0))
Sheet1 is fairly static, but Sheet2 (Anomalies) is being updated all the time. I could just hide column C and then column B will update based on that, but I'd prefer a cleaner solution.
I've tried joining the two formulas, by replacing the INDIRECT part with the second formula, as per the following: HYPERLINK("#"&CELL("address","Anomalies!A"&MATCH(A54,Anomalies!A:A,0)),A54)
but I get an error.
View 5 Replies
View Related
Jan 7, 2014
I was able to get VBA to post this relative reference, which sticks the formula
=DATE(YEAR($D2),MONTH($D2)+6, DAY($D2)+1) into a cell in Col J.
All fine and dandy, works as it should with this formula.
Code:
.Cells(Row, "J").FormulaR1C1 = "=DATE(YEAR(RC4),MONTH(RC4)+6, DAY(RC4)+1)"
However, when I try this with a different formula =IF(ISNUMBER(SEARCH(C2,H2)),"REPEAT","SAFE"), I'm getting a compile error: Expected end of statement with this code:
Code:
.Cells(Row, "I").FormulaR1C1 = "=IF(ISNUMBER(SEARCH(RC3,RC8)),"REPEAT","SAFE")"
The error message highlights the word REPEAT. I suppose it's something with all the quotes throwing off where compiler thinks the end of the formula should be.
View 3 Replies
View Related
Dec 28, 2006
When I copy the formula to another cell, It doesn't show the result. But when I double click on it, it works. For example
there r values in A1 as "john" & A2 as "Jack". I write formula =A1 in cell B1. It shows "John". Now I copy this formula to B2, it shows "john" instead of "Jack" . When I double click on B2 & enter, it shows "Jack".
View 2 Replies
View Related
Aug 13, 2013
I am migrating a bookkeepping spreadsheet from Quattro v12 (c2001) to Excel 2007 and have hit a stone wall over relative 3-D references.
In this workbook each sheet holds data for one month, and this includes some lagging-12-month calculations -- that is, summing a range on a single cell for the preceding 12 sheets (including this one).
Unexpectedly, this formula:
=ISUM('201206:201305'!M6)
gives absolute references, even though I put in no dollar signs after the sheet names. This means it gives the wrong answer when copied to the next sheet to start a new month.
I can find no reference at all to converting the above formula from absolute to relative reference.
View 5 Replies
View Related
May 26, 2009
I'm working on setting up a chart. The formula I'm using for cell B21 is this: =ROUND(F3,0) & " " & IF(E3<F3 ...
View 2 Replies
View Related
Feb 4, 2014
I have encountered some difficulty in modifying a macro I wrote into what I need. I created a macro that searches a column (Column C) for a cell value of, "stop", and then it copies everything above that cell and pastes it onto another sheet. In the sample data set that I was using, "stop" first occurred in cell C541, so the macro copies C1:C540 and pastes it onto another sheet. The problem is that the macro created an absolute reference to C540. What I desire is for the macro to use the 'Find' function to locate the first occurrence of, "stop", offset one cell above that cell, and then reference the active cell (which was positioned by these last two steps) in the range that should be copied. Basically, I'm hoping to have cells C1 through the active cell copied and then pasted onto another sheet.
Code below.
Sub FAIL()
'
' FAIL Macro
'
'
Sheets("Reformatted").Select
Columns("C:C").Select
Selection.Find(What:="stop", After:=ActiveCell, LookIn:=xlValues, LookAt _
[Code] .......
View 4 Replies
View Related
Jun 24, 2008
I am currently working on a data analysis project (data mining) and need to collect and later analyze statistics for the inputs which control a series of calculations. These statistics are shown in the Statistics 1, Statistics 2 and Statistics 3 cells in the workbook that I attached. The inputs are X,Y; all possible values for these inputs are listed in the N,O columns. Basically I need a macro which would take the values from these two columns and place them pair after pair into the controlling cells (K3, L3), then it would copy cells H2 through L3 (updated stats) to a new sheet after each copy operation - so that I will finally have a list of statistics for all of the input pairs.
View 3 Replies
View Related
Jul 15, 2014
I'm trying to use a variable as a cell reference in a formula using '&', but can't seem to get it to work. I've looked through the forum, which have examples of how to do this using a range, but not just as a single cell reference. This puts the formula '=VLOOKUP("A & lastrow &"" , Vlookupinput, 2,0)", which obviously gives me an error.
My code is:
Code:
Dim lastrow As String
lastrow = Range("A" & Rows.Count).End(xlUp).Row + 1
ActiveSheet.Range("A" & Rows.Count).End(xlUp).Offset(1, 1).Select
ActiveCell.Formula = "=VLOOKUP("A & lastrow &"" , Vlookupinput, 2,0)"
View 5 Replies
View Related
Jan 13, 2009
Not been around for some time now but have to do my annual update for this workbook and implement some new changes.
In the attached example workbook, I have created some formulas which reference a particular cell for each client e.g.
View 2 Replies
View Related
Sep 28, 2006
I want to create a formula of the form: =INDIRECT(ADDRESS(4,2,2,TRUE,($A9) and insert this in a cell BUT the $A9 reference needs to reference the row of the cell where the formula is being inserted which will vary. ie. A30, A31, etc. How do I do this?
View 2 Replies
View Related
May 17, 2008
I will show with an example of what I would like to do. I italized and underscored the part of the formula.
---A----B
1 24 formulaB
formulaB = "= CELL("contents",DifferentSheet!G(A1))"
I want B1 to contain the value from the cell G24 in sheet "DifferentSheet". I want to use the value in A1 to determine what row on "DifferentSheet" I should use.
View 2 Replies
View Related
May 28, 2008
I am trying to do a "getpivotdata" formula on a cell in certain file that gets info from a pivot table on another file. However the name of the second file (the one where the pivot table is found on) might be different each time so I created a variable for the second file name but I can’t figure out a way to use this variable in the get pivot data formula as I am not very experience with VBA.
Template = Application.InputBox("What is the name of the file ending with (.xls)")
If Template = False Then
cont1 = MsgBox("Please write the name correctly using (.xls)!", vbOKOnly)
If cont1 = vbOK Then
Exit Sub
End If
End If
View 3 Replies
View Related
Jan 9, 2014
I am an architect and recently I was required to do some extensive calculation relating to water requirements and toilet requirements for a building that i was designing. i created a excel file, with a basic vlookup function to put certain values in the cells that are pre-defined for a particular building typology (mostly created by governmental bodies as guidelines). for example, when i choose a particular type in column E, column F and G fills up automatically. now this table also gives me occupant load based on what is the area i enter in column D.
The problem is that I want to automate the calculation of toilet requirements. Now, each typology will have a different formula to calculate WC/Urinal/washbasin.
1. there will be 17 different formula - one for each typology (as shown in sheet 5)
2. Column j will calculate what is the number of WC required based on 2 criteria - first id what is the typology and then looking what is the number of occupant.
The problem here is for example, if in E9, selected typology as "offices", the formula of offices typology will be used in J9 and occupant value from H9 will be used but if i have E18 also selected as offices typology, the same formula will use occupant value mentioned in H18 instead of using H9.
Hence, excel will first have to look what is the typology selected. based on that, it will load formula - out of that 17 different formula - specific to that typology and finally it will refer to corresponding row for occupant load and will use it in the formula to get the result.
View 3 Replies
View Related
Feb 4, 2010
a user i'm assisting wants to calculate totals by recording a macro that sums all the rows in a column using relative cell references. this is because the user runs a report that pulls in data that varies. one week the report may contain 40 rows that need to be totaled, and the next week there may be 60 rows that need to be totaled.
here's what i did:place cursor in cell where i want total to appear
go to VIEW menu, MACROS tab, and click USE RELATIVE REFERENCES
click RECORD MACRO
enter name, description, assign shortcut key
go to FORMULAS menu and click AUTOSUM
press RETURN
when i test the macro out on columns containing the same amount of rows, it works fine. but when i run the macro on a column with more rows, it only totals the amount of rows contained in the original macro. see attached.
View 3 Replies
View Related
Jun 19, 2008
Creating a named range relative to the active cell? So that I can click on any cell and a named range is created in the adjacent column for 5 rows.
e.g. click cell c5, and a named range from cells d5:d10 is created when i run the macro ...
View 9 Replies
View Related
Aug 21, 2008
From a formula, how can I reference other sheets in my workbook via a relative reference as opposed to needing to know the sheet name? I know I can write a macro, but looking for a non-VBA solution.
View 9 Replies
View Related
Jul 22, 2009
Im trying to get a message box to pop up if the result of a count formula is greater than one; ie. in a list of data to warn of repeats of a certain key reference.
Ive never had a drama with putting a message box in before but ive only based it off a constant reference whereas in this case, it will be based on a relative reference; for example, when inputted a value in A2, that has the same value in A1, the count formula in B2 will be 2, so i want a message box to come up. Same goes if the same value was put in A3, and B3 was greater than
View 9 Replies
View Related
Apr 14, 2007
This is what I need to be doing:
Write cell K5 as a relative reference, absolute reference, mixed reference with the row varying, and mixed reference with the column varying.
How do I do that?
View 8 Replies
View Related
May 8, 2009
I have recorded macros in the attached file to highlight cells that contain matching initials by using conditional formatting on the first cell and copying it to the remaining cells. The problem is that if rows are inserted above that change the first cell reference then the macro no longer works properly. Is there a way to use a relative cell reference within the macro? The macro buttons are in cells A4 to A13. I have no VB experience and created the macros by recording keystrokes and using tips found in this forum.
View 14 Replies
View Related
Jun 16, 2014
I'm trying to do is delete a row of chosen cells in my form (form is locked with a password) using a macro then return back to the first cell below the deleted row. When I run the macro what's happening is that it's returning back to the cell chosen while writing the macro (which is at the very top A7). So if I'm several rows below A7, it deletes the row and then returns all the way back to the top of the form causing the user to have to scroll back down to where they were
View 3 Replies
View Related
Jul 8, 2008
I seem to be having problems with using relative RC in vba within an automated reporting spreadsheet..
in my 'left lookup' below.. the R seems to point to row 1 no matter what row i am writing to..
View 11 Replies
View Related
Aug 26, 2009
I need to drag a cell using a macro and using relative reference.
i.e. drag activecell to activecell.offset(1,-1)
View 3 Replies
View Related
Apr 4, 2014
I have an Excel workbook with multiple worksheets. One of the worksheets has a live data feed for stock updates. I extract data from the live feed (it's in multiple sentences) and pull it into 6 columns. In another worksheet, I pull those 6 columns into the sheet through the use of Index / Match. That second sheet has additional formulas that essentially analyze the data. As the data refreshes, the existing data moves down the column.
What I didn't think about was the fact that at times, a stock may be listed several times because different brokers are offering updates. Because I used Index / Match, it will look for the first match from the top and display that data in the relevant columns. Unfortunately, some of the data needs to stay with the matching row (and stock ticker) but because of the way I wrote the formulas in Index / Match, it just finds the first matching target and displays that data.
I can correct this by using an absolute reference ($) but I can't find a way to "copy down" formulas using absolute references. I also have one column of cells that contain 1 absolute reference and one relative reference.
I'll re-write this manually if I have to but I have 1,800 cells to change.
View 2 Replies
View Related
Aug 11, 2006
I went to record a macro but I can't seem to get the relative reference button anywhere. I am using Excel 97 - does anyone know why this might be or how I can get it back?
View 9 Replies
View Related
Nov 27, 2006
I am dealing with a workbook that will hold an undetermined amount of worksheets. Each of these worksheets will have have a series of numbers that are summed to a total within one cell. Lets say cell A10. For every spreadsheet, no matter what, this number will be stored in cell A10.
My first sheet will then be a master listing of all the other sheets in the workbook. In column A I will have the names of each sheet and in column B I want excel to list the value of A10 for the corresponding sheet listed in column A
So normally it would look like this on the master sheet
A | B
Sheet 2 | =Sheet2!A10
Sheet 3 | =Sheet3!A10
Sheet 4 | =Sheet4!A10
Where the formula would give me the value of A10 in the respective sheet.
What I would like to do is, within column B, I want to replace the sheet reference with the cell that contains the name of the sheet. So it would then be a formula similar to the below setup(Although this does not work because I have tried it)
A | B
Sheet 2 | =A1!A10
Sheet 3 | =A2!A10
Sheet 4 | =A3!A10
The hope is that excel would substitute in Sheet 2 for A1 and there by give me the sheet reference that I need. This way I can continuosly add sheets to the workbook and as long as I have the correct Sheet names in column A, all I need to do is drag the formula down column B and I will pull all of the necessary information without having to retype the formula each time.
View 9 Replies
View Related
Dec 17, 2008
This is one of about 25 sheets in one excel file, and I will be receiving about 5 different files a week, so a macro is necessary to save time. I tried to create a macro just by recording, and it was not able to adjust to the variances in the number of lines between the sheets.
I need it to do the following, and more or less in this order:
-Delete Column A
-Create text and format A1:C1
-Sort rows 2 through the last row based on column C values (from largest to smallest, although its not shown in the picture above)
-Create a sum at the bottom
-Apply grid lines to all the data
I don't have a problem with the first two, but I cannot figure out how to adjust for the number of rows for sorting, offset 1 cell down to create the sum formula below the data, or how to properly write the macro for the sum formula itself. When I recorded the macro, it used cell references like Range("C5").Select and others which do not adapt to the varying number of rows.
I tried using the offset command in this thread without much luck.
This is some of the macro I have:
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
ActiveCell.FormulaR1C1 = "Customer ID"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Customer Name"........
View 9 Replies
View Related
Mar 7, 2007
I have a workbook with 50 worksheets, each worksheet has an Alpha name (ie names of people). Rather than write some code to go through each worksheet to create a report, is it possible to write a formula in a "Reports" worksheet that reads something like
=worksheet10!f2
where worksheet10! is the number of the worksheet (as seen in the VBA project window) while the name is "Billy".
View 9 Replies
View Related
Apr 10, 2007
When I click Tools Macros Record New Macro I usually get a box which allows me to chose relative reference and is displayed until I click stop.
View 4 Replies
View Related