Dynamic reference in excel from cell - excel

I would like to get reference for row from another cell but fix column.
For example:
This is normal way. In cell A1 will be YES
| - | A | B |
| -- | -- |-- |
| 1 | =B1|YES|
| 2 | 1 |NO |
I'd like to chage number 1 in =B1 to be read from cell A2. something like
-
A
B
1
=B(A2)
YES
2
1
NO
Why? Because then i will change number in cell A2 from 1 to 2 then will change cell A1 from YES to NO

You can use INDEX formula to get the desired results like below in cell B2.
=INDEX(C:C,A2)

Related

Vlookup doesnt read mixture of Alphabet and Numbers eg: 1T902462K01

i have a table as below and i wanted to compare result using Vlookup.
A | B | C
-------------------------
1 | ID | Name | Lot
-------------------------
2 | 70100 | Krenn | VF849062
-------------------------
3 | 70101 | Georg | VE803354
-------------------------
4 | 70102 | Mohd | VE803354
However =VLOOKUP(C2,A1:C4,1,FALSE) will result #N/A
Any advise?
Regards,
Zaiem
Try the Index/Match suggested in the comments. It goes like this:
=index(A1:A4,match(F1,C1:C4,0))
in words: find the value of F1 in the range C1 to C4 and return the value from column A for the same row.
Your Vlookup formula references C2, which does not make sense if column C is the column where you perform the lookup.

Check if cells match in two columns and, if they do, copy a related value

Given a column A of 100 names and another B of numbers, where column C contains a subset of those numbers how might I populate column D with the matching name? A match is where the names in A and D are next to the same number. For example, A, B and C are inputs and D the desired output:
____A______B_______C_______D____
1 |Larry | 11111 | 22222 | Bob |
2 |Bob | 22222 | 44444 | Steve |
3 |Mike | 33333 | 55555 | Jim |
4 |Steve | 44444 | | |
5 |Jim | 55555 | | |
Please try in D1 and copied down to suit:
=INDEX(A:A,MATCH(C1,B:B,0))
Not quite sure if this is what you are looking for, but a Vlookup function should help you greatly. I used a helper column to link C1 = A1, C2=A2 and so on. You can hide this column if you need to. You can then use the formula shown below in cell E1 and drag it down. As you put numbers in column D, the name will automatically fill in column E with the matching code.

Creating an SQL select statement out of excel values

I have a sheet with 2 columns. I need to CONCATENATE the two cells within each row to create a large WHERE statement in the SQL based off every row. For example:
Where A1 = 'B1' and A2 = 'B2' etc etc.
What do you suggest is the best method to do this? I need to do this across many sheets. Originally I was going to do something like this: C1=CONCATENATE(A1," = ","'",B1,"'") across every row, then CONCATENATE those outputs as well (C1,D1 etc) but just wondering if there are any other options? Would using VBA be easier?
No need to use any functions.
You may do like this,
assuming your excel sheet is like:
| A | B | C | D |
1 | a1 | b1 | | |
2 | a2 | b2 | | |
3 | a3 | b3 | | |
4 | a4 | b4 | | |
Insert one new row between A and B, and write =' in cell B1 and drag that cell to COPY cell value upto total number of your rows. Similarly write ' and in Cell D1 and do same, so it will be like this.
| A | B | C | D |
1 | a1 | =' | b1 |' and|
2 | a2 | =' | b2 |' and|
3 | a3 | =' | b3 |' and|
4 | a4 | =' | b4 |' and|
Now, Copy paste these cells to Notepad++ and replace TAB and \n by a space (new lines)
So, now you should get string like,
a1='b1' and a2='b2' and a3='b3' and a4='b4' and
You just have to edit minor thing, place this to your query and remove last and

Using a number in a cell to generate a cell reference

What I want to do might be better achieved with a database, however I have very limited experience with them, and only have to change the information infrequently.
What I have is a sheet where each row has 8 cells of relevant data.
What I want to do in another sheet is to enter a number into 1 cell, and have a group of cells below use that number to reference data in the other sheet.
For example, in Sheet1 I could have the following (fig 1):
| A | B | C | D | E | F | G | H
-----+-----+-----+-----+-----+-----+-----+-----+-----
101 | Dep | 700 | Sta | 100 | Sta | 300 | Dep | 900
What I want to achieve in sheet 2, by typing the row number into 1 cell, is to have the data in those 8 cells copied below, for example (fig 2):
| A | B | C | D |
-----+-----+-----+-----+-----+
1 | "Row Number" |
-----+-----+-----+-----+-----+
2 | =A# | =B# | =D# | =C# |
-----+-----+-----+-----+-----+
3 | =E# | =F# | =H# | =G# |
-----+-----+-----+-----+-----+
And yes, I am aware those formulae above do not reference the other sheet - this was to save space.
Which, if using the example row above, should look like this (fig 3):
| A | B | C | D |
-----+-----+-----+-----+-----+
1 | 101 |
-----+-----+-----+-----+-----+
2 | Dep | 700 | 100 | Sta |
-----+-----+-----+-----+-----+
3 | Sta | 300 | 900 | Dep |
-----+-----+-----+-----+-----+
So, in that example above (fig 3), what do I need to put in as a formula in cells A2-D2 & A3-D3 to automatically use the number in A1 as part of the cell reference to print the data from the other sheet.
Does that make sense? I hope so because I have over 300 lines to enter into my 1st sheet and another 70 lines x 7 blocks of columns on the second sheet.
Lastly I just want to say I want to avoid programming languages, like VBA, wherever possible.
Check out the INDIRECT() function.
For cell A2 in your example on the second sheet, enter:
=INDIRECT("Sheet1!"&"A"&$A$1)
Expand this formula to the apply to other target cells by changing the "&"A" portion to reference columns B, C, D, etc. from Sheet1 as needed in your grid per the following example:
=INDIRECT("Sheet1!"&"B"&$A$1)
=INDIRECT("Sheet1!"&"C"&$A$1)
=INDIRECT("Sheet1!"&"D"&$A$1)
These formulas will reference your selected "Row Number" in cell A1 and pull the related data from Sheet1 into Sheet2.
You can do this using the INDIRECT function
Returns the reference specified by a text string.
References are immediately evaluated to display their contents.
Use INDIRECT when you want to change the reference to a cell within a
formula without changing the formula itself.
http://office.microsoft.com/en-gb/excel-help/indirect-HP005209139.aspx

How to get a formula cell from a sheet and change a variable of that formula for just one time?

I have a sheet that do a heavy calculation, with sums, factos and custom functions, that results in a single cell. Imagine a simple series of sums:
| A |
---------
1 | 39 | → This is my variable, everything else is fixed
2 | 800 |
3 | 200 |
4 | =Sum(A1:A3) |
In another sheet, I will like to get the result value of the formula on the Sheet1 A3 cell, however I will like to campare changes on one variable of that sheet, the Sheet1 A1 for that purpose
| A | B |
--------------------------------------------
1 | =X(Sheet1.A4, B1, Sheet1.A1) | 40 |
2 | =X(Sheet1.A4, B1, Sheet1.A1) | 50 |
3 | =X(Sheet1.A4, B1, Sheet1.A1) | 100 |
4 | =X(Sheet1.A4, B1, Sheet1.A1) | 200 |
5 | =X(Sheet1.A4, B1, Sheet1.A1) | 1000 |
That will result in:
| A | B |
------------------
1 | 1041 | 40 |
2 | 1051 | 50 |
3 | 1100 | 100 |
4 | 1200 | 200 |
5 | 2000 | 1000 |
So my question is, X function exist? how can I make it work that way? I Want to get the result of formula on the cell Sheet1.A3, however I want also for that case change the value of the A1 cell to get a different result.
Will appreciate any hint.
I would do this by having another sheet (or another data range in the same sheet) containing the possible values for A1 that you want to test, and then write a small VB macro that will:
Replace Sheet1:A1 with each of those values in turn
Recalculate Sheet1
Copy desired values (A1 and A3) into the relevant cells in Sheet2.

Resources