Table Reference Formula Excel VBA - excel

I'm using a formula to lookup-up values from a table in excel. The formula is added to a cell via VBA.
The formula is in use on two sheets, looking up the same information from a table on a third sheet.
In it's entered form the formula is:
=IFERROR(INDEX(PSE_Data[#All],MATCH($F7,'PSE Data'!K:K,0),16),"")
When I record adding this formula through VBA on one sheet it is recorded as:
=IFERROR(INDEX(PSE_Data[#All],MATCH(RC6,'PSE Data'!C[-12],0),16),"""")
on the other sheet it is recorded as:
=IFERROR(INDEX(PSE_Data[#All],MATCH(RC6,'PSE Data'!C[-2],0),16),"""")
I understand that the C[-2] and C[-12] must be some sort of referencing for the column within the table, but what I don't understand is why that reference would be different when using the formula in separate sheets. Could someone explain or point me in the right direction of some resources?

Related

Making the Indirect formula more dynamic by making it change the row (cells) referenced in the formula

I have three excel sheets that are set out the same (they are filled with the same tables but have different values). I have now created another excel sheet which is suppose to sum the values at each cell. For example, take cell G10. All values in this particular cell, across these three excel spreadsheets are summed and presented in this new summary excel sheet. I have created the following ‘indirect’ formula to do it. (I want to use indirect formula as it refers to the name of each worksheet. It is appropriate for this workflow).
Equation (at cell G15)
=SUM((INDIRECT($G$2&"!G15:AV15",TRUE)),(INDIRECT($G$3&"!G15:AV15",TRUE),(INDIRECT($G$4&"!G15:AV15",TRUE))))
($G$2, $G$3,$G$4refers to the worksheet name;
G15:AV15 refers to the particular range…)
The formula works for the particular row, however I want to be able to copy and paste this formula to other cells below and get excel to recognise and change the row number accordingly…
Ie when I copy this formulae to cell value G20, I would want the formula change to reference “G20:AV20.” Does anyone have any recommendations??

How to stop Microsoft sheets from skipping a row with my formula when a new answer is entered on Microsoft forms

Got a formula (shown below) that I am trying to apply to Microsoft form answers. Microsoft forms appears to automatically insert a new row with every submitted answer which prevents the formula from working on the correct referenced cell. Is there a formula on Microsoft excel online that will reference correctly when the form inserts a row?
If I manually drag formula down it updates properly and shows correct cell reference. Tried importrange and query to link the data from the form excel sheet to another sheet but these functions aren’t included on excel online. I also tried indirect function but I could not modify my existing formula to work with it.
=IF(RAW!M2<>””,RAW!M2,””) This formula transfers data from “RAW” data sheet to a separate sheet and leaves cell blank if no entry is found in the source cell.
If inserting rows breaks references, you can use Index with a row number.
Instead of
=IF(RAW!M2<>"",RAW!M2,"")
use
=IF(Index(RAW!M:M,row(A2)<>"",Index(RAW!M:M,row(A2),"")
When copied down, the reference to A2 will change from A2 to A3 and so on and the returned value will change accordingly. The formula will always return the value from row 2 if the formula references Row(A2), regardless of rows being inserted or deleted.

Vlookup formula in excel

I was hoping someone could offer me a little help please on a formula. In one of my cells I use a vlookup to search for the colour in B12 and match it to the colour on another worksheet called cars.
Now this works perfectly fine, but after running the formula I have to select the last row of data and press control & d, or drag down the cell up until the last cell, my question is that is it possible to add this forumla into the cell and have it automatically run all the way down to the last row of data? my forumula is
=VLOOKUP(B12,coloursc:carsc,2)
You can use an Excel table for your data entry. Formulas and formatting will automatically be applied to any new row in the table. You no longer need to manually copy down or pre-fill empty areas of the spreadsheet with formulas.
Learn more about tables in this Microsoft article and this tutorial on Contextures.com

(excel 2013) Dynamic change of formula depending on number of items in another sheet

i have a specific problem to solve. I dont know how to do it but want to do it without macro or worse without VB script.
I will explain what i have and then what i want to do.
I have (plan to have) many sheets in worksheet. first sheet is some intro sheet, where i have also one column containing name of sheets in every cell. i am using formula "=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,256)" so i can change name of sheet and it will change also name of sheet in intro sheet cell.
so for imagination i have column N and there i have sheet1, under that sheet2 and so on...
Each of sheets have the same construction and same formulas on the same place, so i have each sheet for every goods.
And now what i would like to have. I want to add a formula into intro sheet where i would summarize SUM (add) or something like that. It would take every value form each sheet on the same place on each sheet. so the formula would look something like this: "=sheet1!C4 + sheet2!C4 + sheet3!C4 + .... + 'any sheet'!C4" but i dont know how many sheets i will have and the number will sometimes change and i dont want to edit formula because i plan to have more this kind of dynamic formulas.
i will just add another sheet into column N and every formula using this excel type for cycle would take and recount formula using this dynamic array. i hope you understand what i want. my problem is much more complicated but when i describe it more into detials you would loose the point of my interest.
thanks for any suggestions
edit: but if there is only a solution using VBA script, i will have to use it. i dont want to change formula everytime i add another sheet into worksheet
What you describe is a 3D formula. You can do something like
=SUM(Sheet1:Sheet4!A1)
Excel will sum cell A1 in all sheets from Sheet1 to Sheet4 and any sheets that are between these two. You can insert new sheets and they don't have to be named SheetX.
In order to manage the 3D formulas more efficiently, you could use two sheets like bookends before and after the sheets you want to include in the formula: Insert two sheets called "First" and "Last" and ensure that all sheets you want to sum are arranged between these two sheets. Then on your intro sheet use
=SUM(First:Last!A1)
You can hide the "First" and "Last" sheets and only unhide them when you need to check your sheet arrangements for your formulas.
You can insert new sheets and make sure that they are located between your bookend sheets. Drag sheets in and out between the bookends to include or exclude them from the 3D formula.

How to insert column of cells from one sheet to a single cell of another sheet in OpenOffice?

I have a sheet 'MODELS' with columns of data, each column varies in how many cells (rows). I'm wanting to paste a column from this sheet into another sheet 'COMBINED' into a single cell.
For my first cell in COMBINED, I tried using formula:
='MODELS'.A1:A15
However, this resulted in only displaying the data in cell (MODELS) A1 instead of the entire range (A1:A15).
Is there a formula to accomplish this?
I don't think Excel/OpenOffice has a built-in function to do this. You could write a user-defined function (UDF) or a Macro using VBA to accomplish this. Here's a thread which you might find useful:
http://www.mrexcel.com/forum/excel-questions/16401-concatenate-range-cells.html

Resources