I have a column of data in say A1:A10 in worksheet A. In worksheet B I have a range for data from A1:J1. I need the data from the column in worksheet A to be transposed into the data range in worksheet B. I can Paste Special and paste in the values but I need the information in worksheet A to update automatically that in worksheet B.
Any help or advice is appreciated.
Please select A1:J1 in worksheet B and enter:
=TRANSPOSE('worksheet A'!A1:A10)
with Ctrl+Shift+Enter.
Copy this:
=INDEX(A!$A$1:$A$10, COLUMN())
into your cells A1 through J1 in worksheet B (so that all cells contain the exact same formula).
Basically, the INDEX function grabs a specified element out of your vertical array A1:A10 in worksheet A (the worksheet name is specified before the exclamation point). Which element to choose is given by the second parameter. Here, we simply use the COLUMN() function, which returns 1 for column A, 2 for column B and so forth...
EDIT:
If you want to use a different data column as the source of your data, simply replace the A!$A$1:$A$10 with anything else you like, e.g. Sheet3!$C$10:$C$23.
To place the copied data somewhere differently, copy the formula above into all the target cells, wherever they may be. BUT: If the target cells do not start in column A, you need to subtract an offset from the number returned by COLUMN(), so that you pick element 1 in your first target cell. So, for example if you want to place the data into cells J5 through S5, you will need to copy this formula into each cell:
=INDEX(A!$A$1:$A$10, COLUMN() - 9)
This is because COLUMN() returns 10 for column J, but you want that cell to contain element 1 of your source data column, so we subtract 9 to get from 10 to 1. In column K, COLUMN() will return 11, subtracting 9 yields 2, so INDEX(...) will then return the second data element for that cell, and so on.
Related
I need to compare the B2 Cell value (6012469) with Column A i.e. cell A2 to A10 and return the b2 cell value (6012469) in column C where the value matches i.e. cell C5,C7, C9 AND C10 and NA in remaining cells where the value is not matched.
I have around 15000 rows of data is column A and need to automate the process.
I have attached the sample image for reference.
[1]: https://i.stack.imgur.com/DvzC3.png
Select any cell inside your data range in Column A. Go to your ribbon, click Home > Format as Table. It doesn't matter what colour scheme you choose.
Make sure that all your data in Col A plus Cols B & C are included in the table.
Then, in any cell of your table in Col C (e.g. in C2), paste this formula:
=IF(ISNUMBER(SEARCH($B$2,[#[Column A]])),$B$2,"")
Excel should automatically populate all of your Col C in the table with this formula. (If it doesn't, then you should see a little clickable prompt next to the cell asking if you want to overwrite all the other Col C cells with this formula.)
The table with the Col C formulas would look something like this:
Note: Of course, you could achieve something very similar without using a structured table, but not as conveniently as this because you would have to copy the formulas down to the other approx. 15000 rows. Even the Fill Down feature is not as convenient.
ADDITIONAL: a different formula in response to the asker's request that each cell in Column C match any of multiple values in Column B --
=IFERROR(INDEX($B$2:$B$4,MATCH(TRUE,ISNUMBER(SEARCH($B$2:$B$4,A2)),0)),"")
NOTE: if more than one Column B value matches a Column A cell, Column C will display Column B's topmost match
I have been using VLOOKUP() to populate worksheets with Inventories, however I'm stuck with an issue where one column has the same value in multiple cells, I need to match 2 cells from sheet 2 with sheet 1 and have it return the 3rd cell from sheet 1 into sheet 2.
I'm working with about 350 rows in both sheets, and in some cells the same/different values repeat it self hence needing it to match with 2 cells in the same row.
This is the formula I currently use:
=VLOOKUP(A1&L1,'Sheet1'!$A$1:$E$351,3,FALSE)
I'm expecting it to return the value that's in the 3rd column on sheet 1 in the row that matched the values of Cell A1 and L1 in sheet 2. and the same going on A2 & L2 then A3 & L3 and so forth.
Unless you have values in Column A of your 'Sheet1' that are the equal to to concatenation of your values in Columns A and L in 'Sheet2', the formula will not work.
Instead, I'd try FILTER if you have the newest version of Excel. Something like:
=FILTER('Sheet1'!$C$1:$C$351,
(('Sheet1'!$A$1:$A$351=A1)*('Sheet1'!$L$1:$L$351=L1)))
Another option is INDEX. Something like:
=INDEX('Sheet1'!$C$1:$C$351,
MATCH(A1&L1, 'Sheet1'!$A$1:$A$351&'Sheet1'!$L$1:$L$351,0),
3)
The only way to do this task is to use a helper column
Go to Sheet one where the data table is, insert a column at the starting point of data e.g your Data set starting in SHEET1 from the column A. so insert new column in A
use this formula in A1
=CONCATENATE(B1,C1,D1,E1,F1) Press Enter, Drag the formula down to A351
now go to sheet2 and use this formula in the result cell
=VLOOKUP(A1&L1,'Sheet1'!$A$1:$F$351,4,0)
I have an excel workbook with two worksheets.
On one sheet I have data horizontal and my second sheet I have data vertical.
I want on sheet 2 to drag down my reference from sheet 1 data.
I am looking to have column increase not my row increase? Makes sense?
I try to "equal" the cell i want from sheet 1. However when I drag down my reference goes down instead of across.
Any help would be appreciated.
Conceptually: Use Index. The syntax is Index(range,row number, column number)
If you want to transpose a range in Sheet1 to Sheet2, you can use
=Index(Sheet1!$A$1:$J$10,column(A1),row(A1))
Copy across and down.
See how the row argument uses the column command and the column argument uses the row command. That means in the starting cell A1, the INDEX formula will return the column number 1 for the row argument and the row 1 for the column argument, i.e.
=Index(Sheet1!$A$1:$J$10,1,1)
Copy the formula to row 2 and the reference in the column argument will refer to Row(A2), so the formula will translate to
=Index(Sheet1!$A$1:$J$10,1,2)
i.e. it will return the value from the second COLUMN of the index range. See the screenshot for a result. Change the Index range to your desired source.
I have a "Master" sheet with part numbers in column A and locations in column B. I have approx 200 sheets with just part numbers in column A. How can I apply VLOOKUP to all sheets so every part number on every sheet will have my location in column B? It will take forever to do it manually. Thanks
Here is one way to achieve a lookup of data from the Master Sheet, assuming the starting cell containing your lookup value is A2. This also assumes that all sheets are in the same workbook:
=VLOOKUP(A2,Master!$A$2:$B$11,2)
An explanation of what each argument does from left to right:
A2 - cell containing lookup value in one of the 200 sheets. (This can be any cell which contains a lookup value).
Master is the name of the sheet which contains the data to look up.
$A$2 is the top left cell for the table data to look up in the Master sheet, we want to use $ sign because the lookup table top left cell should be fixed.
$B$11 is the bottom right cell for the table to look up in the Master sheet, we want to use $ sign because the lookup table bottom right cell should be fixed.
2, this is the column index which includes value you want returned for a successful look up. The column index starts at 1 and increases to the right, The column at index 1 contains the lookup values. In your scenario, index 1 is Column A and specifying an index of 2 will index column B
To deal with blank cells or cells which are not found in the table you can extend this formula like so:
=IF(ISNA(VLOOKUP(A2,Master!$A$2:$B$11,2)),"",VLOOKUP(A2,Master!$A$2:$B$11,2))
This formula will do the lookup, if it does not find the value it is looking for it will leave the cell blank, otherwise it populates the cell with the found data.
You can now copy and paste to cell A2 (or replace A2 with starting cell) and then drag the formula down the column to the last cell that requires VLOOKUP from the data table in the Master sheet. For every row X, it will update the lookup return data for the corresponding lookup value.
You will need to copy the formula then drag it to fill the entire B column for each 200 sheets which is a bit tedious. An alternative is to write a macro which loops over each sheet in the workbook and populates the corresponding column with the result of the lookup from the Master sheet.
VLOOKUP works when the lookup value is in some column X and the value to return, the data, is to the right of X.
If the data to be returned is to the left of the lookup value, you must use a combination of MATCH and INDEX which is slightly more complicated.
To lookup data in a different workbook, you will need to create a link between the two workbooks, this article explains how to do so.
Think about changing all your data to a single sheet. You may try this home made function:
Function AllSheetVLookup(ByVal lookup_value, ByVal search_col As Long, ByVal return_col As Long, Optional book_rng As Range)
Dim ws As Worksheet, r As Long
On Error Resume Next
For Each ws In IIf(book_rng Is Nothing, Application.Caller, book_rng).Worksheet.Parent.Worksheets
r = Application.WorksheetFunction.Match(lookup_value, ws.Columns(search_col), 0)
If r Then AllSheetVLookup = ws.Cells(r, return_col): Exit Function
Next
AllSheetVLookup = CVErr(2042) 'Not found, #N/A! returned
End Function
lookup_value - value to search, has in VLOOKUP;
search_col - column number in worksheets where to search for value
return_col - column number to return value from matched with match
book_rng - optional. Cell in another book if another book is to be searched. If ommited, book where function is called is used.
Example:
=AllSheetVLookup("part_number", 1, 2)
Will search for value "part_number" in column A (1st) from all worksheets of current book, and return value of column B (2nd).
I have a Macro in my Excel and this Macro writes a formula to one cell in my Excel sheet.
The code of my Macro that does this is like below:
Range("F10").Select
ActiveCell.FormulaR1C1 = "=SUMIF('1'!C2,C7,'1'!C[2])"
and the Formula produced for the F10 cell is like below:
=SUMIF('1'!$B:$B,$G:$G,'1'!H:H)
Can someone help me understand this code? What does '1' , ! , [] and ... do exactly?
In general I want to know what is the output of " =SUMIF('1'!$B:$B,$G:$G,'1'!H:H)" and why the macro generates this formula?
You have chosen unfortunate sheet names.
"=SUMIF('1'!C2,C7,'1'!C[2])"
The '1' is the sheet name. Sheet names can be wrapped in single quotes, but you only need to do that if the sheet name contains a space.
The ! is a separator between sheet name and cell reference.
C2 means column 2, which is column B. You are using R1C1 syntax for the formula, so the C identifies the following number as related to a column.
C7 means the 7th column, so, column G.
'1'! again means the sheet name and the separator.
C[2] means from the current column (the C) go 2 to the right. If the formula returns column H for that, it means that the current cell must be in column F.
R1C1 referencing is not widely used in worksheets these days, but in VBA it makes relative cell referencing very easy. The brackets mean "relative to the current location" and the R or C will determine whether it's a row or column that needs to be traversed.
R1C1 is Row 1, column 1, in other words, cell A1. This is an absolute reference.
R[4]C[-2] is a relative reference. It will be evaluated based on the current cell and from that position will add 4 rows (positive value 4 for rows) and subtract 2 columns (negative value -2 for columns). So, if the current cell is H4, which translates to R4C8, a reference to R[4]C[-2] means F2.
So I'm assuming you know what
=sum($B:$B)
does? If not, then you need to take a basic Excel tutorial before aksing this quesiton.
!
The $B:$B in my formula is the range. It refers to the range that is the enitre column B on the current worksheet. If you wanted to sum up column B on a different worksheet then you specify that range like worksheetname!$B$B or if the worksheet name has spaces in it then use quotes like 'worksheet name'!$B$B.
Hence '1'!$B$B refers to column B on a worksheet named '1'
[]
So what do the square brakcets do? That is from the R1C1 notation. So normally you reference a range absolutely. So when you use a range like $B$B, you are refereing to column B no matter where you call that function from (i.e. no matter which cell your function is in). R1C1 notation is Excel's way of allowing to refer to cells relatively, or in other words refer to their locations relative to the cell your formula is written in. c2 in R1C1 notation is actually still absolute, it means the second column (i.e. B). c[2] is now relative, the [2] means two columns to the right of the cell your formula is in.
SUMIF
SUMIF is an excel formula that only sums up the portion of a range that meets a certain condition. In your case we cannot say what it will output because we don't know what is in your sheet. But basically for
=SUMIF('1'!$B:$B,$G:$G,'1'!H:H)
The '1'!$B:$B is the range of values you want to test your condition against, the $G:$G is your condition (which I think should point to a single cell rather than a range btw...) and finally '1'!H:H is the range of values that you want to sum.
So if you want to sum values in columns H only when the values in column B are greater than 10 and you sheet 1 looks like
B G H
________________
1 | 5 '>10 1
2 | 12 2
3 | 13 3
The result of =SUMIF('1'!$B:$B,$G:$G,'1'!H:H) will be 5 (i.e. adding 2 and 3 from column H because in column B 12 and 13 were larger than 10 but 5 was not and thus does not meet the criteria for being part of the sum.