Advanced Find And Replace In Excel - excel

I have a product list excel sheet, and category list excel sheet.
In the category excel there is cat_id and cat_name one corresponds to the other.
I need to do a find and replace on every cat_id and replace the numbers in the product list with the cat_name.
How would I do this in excel?

I do not think you can achieve what you are looking for with just Excel formulas in one step. However, you could use the following approach.
Let's assume that the product list sheet is called ProductList and the other one is called CategoryList. Also, let's say that the cat_id items on sheet ProductList are in column A and the cat_id and cat_name columns on sheet CategoryList are in columns A and B.
First you have to make sure that the items on sheet CategoryList are sorted in ascending order on cat_id. Then, in a cell on the first line of an empty column on sheet ProductList (let's say that is cell Q1) , enter the following formula:
=LOOKUP($A1,CategoryList!A:A,CategoryList!B:B)
Then select cell Q1 and drag the lower right corner all the way down until the end of the data in your sheet. After this, column Q will contain the desired values.
To actually replace the original values in column A with those in Q, you need to copy whole column Q and do "Paste Special" into column A, where you select the radiobutton "Values". After that, you can delete the temporary column Q.
If you want to be robust with regard to cat_id items not present on sheet CategoryList, you could add a check, which makes the formula as follows (on one line):
=IF($A1<>LOOKUP($A1,CategoryList!A:A,CategoryList!A:A),
"Not Found",LOOKUP($A1,CategoryList!A:A,CategoryList!B:B))

The Powershell script extension PSExcel have some join feature:
PSExcel: https://github.com/RamblingCookieMonster/PSExcel
Method:
Join-Worksheet -Path
I have tried the search and replace with success.
Also refer to my answer here:
Perform find & replace in excel doc in C#

Related

Excel: Convert Column of Duplicates into a New List, AND THEN create into a DROPDOWN LIST

I have a CSV Product Export from Shopify. I am creating a manual offline quote sheet for furniture items.
Column B = Product Title
Column A = Product Title's Handle (obtained using an Index formula)
PROBLEM:
Column D = Duplicates need to be converted into a list.
THEN using above formula add to a new cell for a Drop Down list (Add formula into Data Validation:Source.)
Note based on the image diagram: Ref 'I2' is located far top left where it says 'Aurora Chair 4 Leg'
NOTES,
And this formula is enetered into 'I3',
=XLOOKUP(I2,A2:A16,D2:D16)
.. but, this formula only returns 'D2', not D2:D5
I also unsuccessfully tried,
=indirect(I2,A2:A16,D2:D16)
=XLOOKUP((I2,A2:A16,0)RANGE D2:D16))
=index(I2,A2:D16)
=FILTER(A2:D16,D2:D16=I3)
{=SUM(COUNTIF(A2:A16,D2:D16))}
=COUNTIF(A2:A16,VLOOKUP(I3,D2:D16,1,0))
You can use this formula for a unique list of filtered values:
=UNIQUE(FILTER(D2:D16,A2:A16=I2))
You can't use this formula as a data validation source :-(
Therefore you have to put it somewhere (hidden) on the sheet, e.g. into cell K2.
And then refer to it as K2# in the data validation source.
Edit according to comment:
To show the values in a row instead of column you use:
=TRANSPOSE(UNIQUE(FILTER(D2:D16,A2:A16=I2)))

Return Value if 4 columns match in Excel

I have 2 sheets that I am working with in Excel:
1) Master Price Sheet
2) Entry
My "Master Price Sheet" sheet includes specific lumber dimensions and specifications as well as an assigned pricing (There are probably 200 different options available for pricing purposes so it takes a long time to manually look up each price)
When I am entering lumber lists into my "Entry" sheet. . .I'd like to return the value from the column "Price" from the "Master Price Sheet" only if the values in columns "Size (W)", "Size (H)", "Length", and "Species" entered into the "Entry" sheet matches columns in the "Master Price Sheet" so that it can find the pricing for me
What formula would be able to help me out with this?
Any help you can provide would be greatly appreciated
I've added images to this post below so that you can see what I'm working with
The easiest way is probably to create a helper column in both tables, where you combine the four cells with an ampersand & sign. This will create a unique key that you can use in a lookup function like VLoookup or an Index/Match combination.
For example: in the Master table, insert a new column before the price and in that new column use the formula (starting in cell G3
=A3&C3&D3&E3
Do the same in the Entry sheet table. Then you can look up the price like this in cell H3 of the entry table:
=vlookup(G3,'Master Price Sheet'!F:G,2,False)
Copy down.
This is the basic principle. You can add more refinement by error catching, so you don't get errors if rows are empty. One of many approaches would be to wrap the formula in an IfError, or check that all four cells have content before performing the Vlookup.

Data validation (Drop down) to auto-populate column with formula

I'm trying to make an excel sheet a lot smaller and easier to handle. What i'm trying to do is have a drop down auto-populate a whole column.
My original sheet looks like:
Item Name(A1) Item Code(B1) Price1(C1) Price2(D1) Price3(E1) Price4(F1)
My goal is to look like:
Item Name(A1) Item Code(B1) Price Drop Down(C1)
I also want to be able to delete an item in Column A and still be able to have the correct values. My VLOOKUP only uses 1 column and wont change (of course) when I switch to a different price set.
You could try something like this:
Copy your original table to another sheet (sheet2), so you can use it as the lookup table. In the original sheet delete the last 4 columns (C:F). Next create a dropdownmenu in cell C1, with items {price1 ,price2 ,price3 ,price4}. Put the following formula in cell C2 and copy down.
=VLOOKUP(A2,Sheet2!A:F,RIGHT($C$1,1)+2,FALSE)
The last parameter [FALSE] is necessary when the item names in the lookuptable are not in alphabetical order.

Excel: If Cell in Column = text value of X, then display text (in the same row, but different column) on another sheet

This is a confusing request.
I have an excel tab with a lot of data, for now I'll focus on 3 points of that data.
Team
Quarter
Task Name
In one tab I have a long list of this data displaying all the tasks for all the teams and what Quarter they will be on.
I WANT to load another tab, and take that data (from the original tab) and insert it into a non-list format. So I would have Quarters 1,2,3,4 as columns going across the screen, and Team Groups going down. I want each "task" that is labeled as Q1 to know to list in the Q1 section of that Teams "Block"
So something like this: "If Column A=TeamA,AND Quarter=Q1, then insert Task Name ... here."
Basically, if the formula = true, I want to print a list of those items within that team section of the excel document.
I'd like to be able to add/move things around at the data level, and have things automatically shift in the Display tab. I honestly have no idea where to start.
If there is never a possibility that there could be more that 1 task for a given team and quarter, then you can use a formula solution.
Given a data setup like this (in a sheet named 'Sheet1'):
And expected results like this (in a different sheet):
The formula in cell B2 and copied over and down is:
=IFERROR(INDEX(Sheet1!$C$2:$C$7,MATCH(1,INDEX((Sheet1!$A$2:$A$7=$A2)*(Sheet1!$B$2:$B$7=B$1),),0)),"")
I came across this situation. When I have to insert the values into a table from an Excel sheet I need all information in 1 Column instead of 2 multiple rows. In Excel my Data looks like:
ProductID----OrderID
9353510---- 1212259
9650934---- 1381676
9572474---- 1381677
9632365---- 1374217
9353182---- 1212260
9353182---- 1219361
9353182---- 1212815
9353513---- 1130308
9353320---- 1130288
9360957---- 1187479
9353077---- 1104558
9353077---- 1130926
9353124---- 1300853
I wanted single row for each product in shape of
(ProductID,'OrdersIDn1,OrderIDn2,.....')
For quick solution I fix it with a third column ColumnC to number the Sale of Product
=IF(A2<>A1,1,IF(A2=A1,C1+1,1))
and fourth Column D as a placeholder to concatenate with previous row value of same product:
=IF(A2=A1,D1+","&TEXT(B2,"########"),TEXT(B2,"########"))
Then Column E is the final column I required to hide/blank out duplicate row values and keep only the correct one:
=IF(A2<>A3,"("&A2&",'"&D2&"'),","")
Final Output required is only from Column E
ProductID Order Id Sno PlaceHolder Required Column
9353510 1212259 1 1212259 (9353510,'1212259'),
9650934 1381676 1 1381676 (9650934,'1381676'),
9572474 1381677 1 1381677 (9572474,'1381677'),
9632365 1374217 1 1374217 (9632365,'1374217'),
9353182 1212260 1 1212260
9353182 1219361 2 1212260,1219361
9353182 1212815 3 1212260,1219361,1212815 (9353182,'1212260,1219361,1212815'),
9353513 1130308 1 1130308 (9353513,'1130308'),
9353320 1130288 1 1130288 (9353320,'1130288'),
9360957 1187479 1 1187479 (9360957,'1187479'),
9353077 1104558 1 1104558
9353077 1130926 2 1104558,1130926 (9353077,'1104558,1130926')
You will notice that final values are only with the Maximum Number of ProductSno which I need to avoid duplication ..
In Your case Product could be Team and Order could be Quarter and Output could be
(Team,Q1,Q2,....),
Based on my understanding of your summary above, you want to put non-numerical data into a grid of teams and quarters.
The offset worksheet function will work well for this in conjunction with the match or vlookup functions. I have often done this task by doing the following steps.
In my data table, I have to concatenate the Team and quarter columns so I have a unique lookup value at the leftmost column of your table (Note: you can eventually hide this for ease of reading).
Note: You will want to name the input range for best formula management. Ideally use an Excel Table (2007 or greater) or create a dynamically named range with the offset and CountA functions working together (http://tinyurl.com/yfhfsal)
First, VLOOKUP arguments are VLOOKUP(Lookup_Value,Table_Array,Col_Index_num,[Range Lookup]) See http://tinyurl.com/22t64x7
In the first cell of your output area you would have a VLOOKUP formula that would look like this
=Vlookup(TeamName&Quarter,Input_List,Column#_Where_Tasks_Are,False)
The Lookup value should be referencing cells where you have the team names and quarter names listed down the sides and across the top. The input list is from the sheet you have the data stored. The number three represents the column number the tasks are listed in your source data, and the False tells the function it will only use an exact match in your putput.

How to use a named column in Excel formulas

I know how to make a named range in Excel.
I have a spreadsheet, with various columns going across as parameters, and then finally a formula in the last cell. This is repeated many times in each row, with each row having a different set of data, and the formula updated to reference the correct row index.
However, the formula looks like (three rows worth):
=G2*(10*D2 + 20*E2 + 5*F2)
=G3*(10*D3 + 20*E3 + 5*F3)
=G4*(10*D4 + 20*E4 + 5*F4)
I would like to use named ranges, but I can't find a way to do something like
=Count * (10*var1 + 20*var2 + 5*var3)
where count, var1, var2, and var3 automatically update to be the particular column of the current row. I can create a named range for every cell, but that isn't helpful. I can name range the column, but then I can't find a way to put an offset into the formula.
Also the whole point of this is readability, so if it ends up being some nasty complex formula function call, that probably doesn't help too much.
Simple, at least when using Excel 2010:
name your column: select full column, enter name
use column name in formula; Excel will combine the referenced column with the current row to access a single cell.
Using the example from Alex P:
select column D by clicking the column header containing the "D", enter name "input1" into name field, and press Enter.
repeat for columns E to F, using "input2" and "input3", respectively.
Do not define additional names defining names "input1" [...] as in example above!
use the formula as given in the example above
Attention:
Using named columns this way, you cannot access any other row as the one your formula is in!
At least I'm not aware of the possibility to express something like <ColName>(row+1)...
I would suggest creating a Table. Select your range A1:H4, then go to the Tables widget > New > Insert Table with Headers (on Mac). This will mark A2:H4 as body of the table, and A1:H4 as header.
From that, you get:
Whatever you put into the header column will define the name for this column automatically, e.g. Count, Radius, Density, Height
You can then write your formula using =[#Count]*(10*[#Radius] + 20*[#Density] + 5*[#Height])
When you change the formula in cell H2, Excel will automatically "copy down" this formula to all cells in column H. So no more accidental inconsistencies in the formulas.
When you need to add another row, simply click the last cell (in our example H4) and hit Tab. Excel adds another row, and also makes sure to "copy down" your formula into the new row.
If you need a total row, add it with the Total Row checkbox in the Tables widget. Excel adds a total row automatically. If you click any cell in the total row, you can change the "total formula" with the "▼▲" button, for example to calculate the Average instead of the Sum of the column.
If you have a long table and scroll down so that the header is not visible anymore, Excel automatically displays the column header instead of the column names (Count instead of G for example).
I can really recommend the video You Suck at Excel with Joel Spolsky which explains all of that.
Suppose I have the following numbers set up in columns D to F in rows 2 to 4:
D E F G
2 10 15 20
3 1 2 3
4 20 30 40
Now suppose I want the value in column D to be known as input1, column E to be input2, and column F to input3:
In Insert > Name > Define...
input1 RefersTo =OFFSET(Sheet1!$D$2,0,0,COUNT(Sheet1!$D:$D),1)
input2 RefersTo =OFFSET(Sheet1!$E$2,0,0,COUNT(Sheet1!$E:$E),1)
input3 RefersTo =OFFSET(Sheet1!$F$2,0,0,COUNT(Sheet1!$F:$F),1)
Now if I write my formula in column G as follows I should get correct answers:
G2 =(10*input1+20*input2+30*input3) // 1000
G3 =(10*input1+20*input2+30*input3) // 140
G5 =(10*input1+20*input2+30*input3) // 2000
I haven't fully reviewed the previous answers, but I think this is closer to what #Jason Coyne the OP was looking for. So, I hope I get a lot of up votes. ;-)
Excel allows your formula to refer to tables and columns by name if you "Format as Table". Here is an article titled Using structured references with Excel tables that goes into detail.
FWIW, it looks like this feature has been available since Excel 2007.
Here is a screenshot of an example:
You should be able to see the formula in E2 is =[#Count] * (10*[#Var1] + 20*[#Var2] + 5*[#Var3]) which is pretty close to what #jason-coyne wanted to type.
I don't like that you are forced to pick a style (or define a new one if you don't see a style you like). The good news is you can reformat the cells all you wish without undoing the "tableness".
It insists on turning on auto-filter. But, auto filter is easy to turn off (see the Filter Button checkbox under the Table Tools Design menu).
It also insists on having non-empty, unique values in the header row (Which kinda makes sense). If you delete a header cell, or insert a column, Excel will invent a new, unique name and stuff it in for you. D'oh!
If you want a column to not have a header, you can enter an apostrophe (') followed by one or more blanks. Remember header values need to be unique, so keep adding blanks if you want more than one column without a header.
If you would like to download the sample workbook in the screenshot, here is a link: https://filebin.ca/3vfaSDn4NLEA/SampleWorkbook.xlsx
Adding to Alex P's answer:
Instead of using =OFFSET(Sheet1!$D$2,0,0,COUNT(Sheet1!$D:$D),1) as the formula for input1, I recommend to use =Sheet1!$D$2:INDEX(Sheet1!$D:$D,COUNT(Sheet1"$D:$D))
It produces the same result, but it is non-volatile, i.e., only recalculate when a predecessor cell changes. This is much better in a larger model!
If you're using VBA, then you can select the whole column and name it, say MyCol, in the name box (upper left input box). The in your code you can refer to a cell in the column MyCol (line 12) using the following code:
Cells(12, Range("MyCol").Column)
You might be able to use the row() function. This returns the current row that you are in. So depending on the layout of the spreadsheet you can use it like this:
=offset(NamedColumn1, row()-1)
The -1 is because you are saying how many rows to move down from row 1 which if you are in row 1 you want to be 0.
Use the Excel feature called named references.
To name a cell or range of cells
select that cell or range of cells
Enter its name in the Name Box ( its left of the formula widget and has the cell name )
You can't use names that conflict with cell names, like k0.
The named cells can be used if formulas. E.g.,
=pi*radius*radius
I'd like to propose a slight variation of the cell reference made by Dror. This will work as well:
Range("MyCol").Rows(12)

Resources