C1 & C2 changes dynamically.
Now, C1 cell has - T[IB_InteractType]={100,111,"111 MMT",180,8008000}
and C2 cell has - T[IB_OverallCSAT]={100,75,50,25,0}
For checking purpose in cell C3 my formula is giving right result. Where as the Indirect function in C5 - =SUMPRODUCT(INDIRECT(C1)*INDIRECT(C2)) is giving #REF! error.
In C3 - =SUMPRODUCT((T[IB_OverallCSAT]={100,75,50,25,0})*(T[IB_InteractType]={100,111,"111 MMT",180,8008000})) gives the right count though.
Please help.
From the Excel help. Syntax INDIRECT(ref_text, [a1]) ref_text:
A reference to a cell that contains an A1-style reference, an R1C1-style reference, a name defined as a reference, or a reference to a cell as a text string. If ref_text is not a valid cell reference, INDIRECT returns the #REF! error value.
Related
I have searched through stackoverflow and found a few topics very very similar to mine, but the answers are not specific and usually are just vba code without any explanation of how it works. Below is what I am trying to do.
1. If empty cell is populated (lets say C3)
2. then input formula into another empty cell at AT3
3. =VLOOKUP(C3,'WC Chart'!A3:G351,3,FALSE) this is my vlookup formula, it works.
I just need it to only populate in the empty cell when c3 has populated text so I need a vba way of doing it.
Like this...
'This line will place the formula in AT3 only if C3 is not blank
If Range("C3").Value <> "" Then Range("AT3").Formula = "=VLOOKUP(C3,'WC Chart'!A3:G351,3,FALSE)"
'This line will place the formula in AT3 and if C3 is blank, formula will return a blank in AT3
'And if C3 is not blank, the VLookUp formula will return an output
Range("AT3").Formula = "=IF(C3="""","""",VLOOKUP(C3,'WC Chart'!A3:G351,3,FALSE))"
How do you retain the value of a cell, for example cell B1 where B1 = A1, after the value of reference cell, A1 is removed?
No, I'm not looking for Copy & Paste Values (V). Is there a VBA code to do this?
As excel clear every variable values at the end of every subroutines. I would like to keep this value for reference all the time.
You set the value to the value, which will remove the references and formulas.
Range("B1").Value = Range("B1").Value
I'd like to know how to pull cell references from the value of another cell and insert them into a formula.
For a simple example:
In cell A1 I have this: COUNT(B4:H4)
Instead of choosing the range when I set up the formula, I'd like this range to be dynamic, based on the value in other cells.
So, I want to type in cell references: in cell B4, I'd type in C5, and in H4 I'd type in C8. How can I set up my formula to look inside cells B4 and H4, but then return the range that is defined by the values in these cells (C5:C8 in this case...)
So in the end, cell A1 would return the count of C5:C8
I hope that makes sense. It seems like something pretty simple but I can't seem to find info on it.
Use INDIRECT()
=SUM(INDIRECT(<start cell here> & ":" & <end cell here>))
I need a function that will do what Excel does automatically when you dreag a formula: change the referneces automatically.
For example:
In A1 I have "= A2 + A3"
If i copy this to say C3 it will have: "= C4 + C5"
I need to WRITE a formula in C3 that will produce this.
Any ideas? VBA solution is also welcome
CLARIFICATION:
In need this to be as general as possible.
Meaning A1 can contain ANY formula of any type, containing references to other cells.
for example: "= A2 + A3" or "= VLOOKUP(A2, $C$1:$E$7, 2, True)"
In need to move have this formula, whatever it is, copied to another cell (say C3), w/o the built in copy/paste, and have the references (that aren't set with $) change relatively.
I thought there might be a function to write in the destination file to do this.
I have tried writing an Eval function, and i managed to copy the formula from A1 and have it evaluated in C3, but the references would not change
This question lacks a bit of clarity, but I think this might be what you're after:
=SUM(OFFSET(C3,1,0,2))
This will sum the two cells directly below the given cell (in this case, cell C3). That is, it offsets C3 by 1 row, 0 columns, and grabs a height of 2 cells and then passes the result to the SUM function.
This VBA code would do what you are looking by setting the formula in the active cell:
ActiveCell.FormulaR1C1 = "=R[+1]C+R[+2]C"
You can use the Indirect() function using relative reference style.
For example, if you were in A1 and wanted to sum B1 & C1, it would look as follows:
A1: =INDIRECT("RC[1]",0)+INDIRECT("RC[2]",0)
That will change as you move the cell around to always sum the 2 cells to the left of the cell.
For your specific example (A1 = A2 + A3 || C3 = C4 + C5), it would be as follows:
=INDIRECT("R[1]C",0)+INDIRECT("R[2]C",0)
Hope that does the trick!!
A very fast way to enter formulas is like this:
Range("E5:H10").Formula = "=A1"
The column and row references adjust, so that for example the formula this code enters in cell H10 is "=D6".
However, that doesn't work for array formulas:
Range("E5:H10").FormulaArray = "=A1"
That puts the array formula {=A1} in each of the cells; no adjustments for rows or columns.
Of course you can loop through all the cells and enter a unique array formula in each one, but that isn't fast.
So I tried this:
Range("E5:H10").Formula = "=A1"
Range("E5:H10").FormulaArray = Range("E5:H10").Formula
But the results were surprising -- the references skip every other row and every other column; for example:
-- The formula in F5 is {=C1} instead of the expected {=B1}, and
-- The formula in D6 is {=A3} instead of the expected {=A2}, and
-- The formula in H10 is {=G11} instead of the expected {=D6}.
WTF?? Why would it skip rows and columns like that?? BTW I'm in Excel 2007 SP3.
For now I'm doing this, which was the fastest way I found that worked:
Range("E5").FormulaArray = "=A1"
Range("E5:H10").FillDown
Range("E5:H10").FillRight
That works but is probably slower than the direct way would be. So -- why does setting the FormulaArray property to the Formula property skip referenced rows and columns as shown above?
The A1 formula is evaluated relative to the top left cell of the range you are populating. So A1 works fine in E5, but B1 is up 4 and left 3 from E5, so the formula entered into F5 refers to the cell up 4 and left 3, which is C1. This repeats for the other cells. The simple solutions is to use:
Range("E5:H10").FormulaArray = Range("E5:H10").FormulaR1C1
since that formula is the same for every cell.