Searching for exact names and copy/paste info - vba

As you can see in the image I have a spreadsheet with different words and codes.
Column A is missing the codes found in column E and I would like to populate column A with the codes found in column E.
Is there a way to do that using a formula, if statement, or VBA macro?

Try this formula:
A2 = VLOOKUP(B2,$E$2:$F$10,2,FALSE)
Where:
B2 the name you want to get the code for
$E$2:$F$10 the range that holds your codes and names
Note:
Your look up range must have the names in column E and codes in column F

Related

Google Sheets Query() Function Returning Unexpected Data

I am having trouble with the QUERY() function in Google Sheets. I'm not certain I am using the correct function to generate the required data. I am far more comfortable with T-SQL, but my wife needs a mailing list generated from her current google sheets.
The facts:
Sheet2 is populated with data from B3:K150
I have a list of names in Sheet2, Column B.
I have a list of addresses in Sheet2, Column G
Sheet1 contains no data other than the data populated in Column B (See below)
Sheet1, Column B is populated with a unique list of names from
Sheet2, Column B using =Unique('Sheet2'!$B$3:$B$150).
Goal:
I would like to populate Sheet1, Column C with Sheet2, Column G
WHERE Sheet1(ColumnB) = Sheet2(ColumnB)
Obviously, using SQL, we would write this as such:
SELECT [Sheet1].[ColumnB]
,[Sheet1].[ColumnC]
FROM [Sheet1]
INNER JOIN [Sheet2]
ON [Sheet1].[ColumnB] = [Sheet2].[ColumnB]
What I have tried:
INSERT the following formula into Sheet1!C3:
=QUERY(Sheet2!B3:K150,"SELECT G WHERE B ='"&Sheet1!B3:B150&"'",0)
Sheet screenshots:
What am I missing?
This worked well for me:
=unique(query(Sheet2!B3:G150,"select B,G"))
as posted by user: pnuts in comments above.
Try this in Sheet1C3 =Arrayformula(if(B3:B=Sheet2!B3:B,Sheet2!G3:G,"")) Let me know if you need me to explain the formula.

Hyperlink a sheet to index page containing $ sign [duplicate]

I am working on Excel report in which I need to pass a link which can take me to a cell referenced.
In below example, I have two sheets on same workbook. Now if I click on cell "A1" on Sheet:1, then it should take me to cell "E1" on Sheet:2.
I know by paste special I can pass hyperlink, but tricky part is data on Sheet:2 is dynamic so I can't go that route.
After looking on Google, I have found out multiple things, so I clubbed them together but it is throwing error "Reference is not valid".
Here is the formula that I've used on cell "A1" on Sheet:1:
=HYPERLINK("[Sample.xlsx]Sheet:2!(ADDRESS(MATCH(""ABC"",BEFORE,0),MATCH(""ABC"",BEFORE,0),1))","ABC")
Here BEFORE is a name range that covers A1 to E1.
Sheet:1
a b c d e
1. abc
Sheet:2
a b c d e
1. x x x x abc
Appreciate your inputs.
=HYPERLINK("[Sample.xlsx]'Sheet2'!" & ADDRESS(1,MATCH("abc",BEFORE,0)),"ABC")
If your sheet name might have spaces then make sure to add the single quotes around the name.

Creating a Dynamic Hyperlink in excel

I have three columns of data (columns A, B, and C).
Column A contains a number
Column B contains a name
Column C contains a URL
In cell E1, I have a drop down list that references the cells in column A.
I need a function that generates a hyperlink based on the number picked from the drop down menu using the cells that are adjacent in columns B and C. In otherwords, if E1 = any cell in column A, then create a hyperlink with the adjacent cells in columns B and C... more generally:
=IF(E1=[Any cell in column A],HYPERLINK([same row column C],[same row column B],"")
Is it possible to create a dynamic formula that will do this? I have found similar questions, but none that ask precisely this, and I cannot seem to piece together my searches to come up with a solution.
thanks to any who help.
enter image description here
I hope you looking for like this
formula:
=HYPERLINK(VLOOKUP(E1;A1:C5;3;0);VLOOKUP(E1;A1:C5;3;0))
I believe (if i'm mentally imagining your spreadsheet right) that you'd be better off using the VLookup function to retrieve the URL. If i'm wrong and it's reversed, the HLookup function may be what you need. They're similar, just depending on the pivot of whether you're aiming for a value in a row (Vlookup) or Column (Hlookup).
This article does a pretty good job of explaining HLookup:
https://support.office.com/en-us/article/VLOOKUP-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
You can then use the lookup value for the HYPERLINK function to set the display text and the URL.

Searching and comparing various values using VBA

I have to create a macro which will:
Get the value from the cell A1 search this value in column C.
If the value in cell A1 exists in column C, the macro needs to be compare the value in cell B1 with values in column D.
If the value in cell A1 exists in column C AND the value in cell B1 exists in column D, then the text "Values found" should appear in cell E1.
The above needs to happen for all non empty rows in column A.
I was trying to use the following formula:
=IF(ISERROR(MATCH(A2,$C$2:$C$138,0)),"Load number not found","Load number found")
But it not working as I want. I have limited access to internet so I can't check all web sites. Would you please help me. Thanks a lot.
To check if A1 is in column C and if B1 is in column D (in the same row A1 was found in column C), then you need to do the following:
=IF(ISERROR(MATCH(A1,$C:$C,0)),"Load number not found",IF(B1=INDEX($D:$D,MATCH(A1,$C:$C,0),1),"Load number found","Load number not found"))
The first IF checks if A1 is in column C, the second IF checks if B1 is in column D (in the same row A1 was found in column C)
It will return "Load number found" only if both conditions are true. Otherwise it will return "Load number not found".
You can write a macro to do the same thing. But the easier way is to lock the cells in column E only and protect the sheet so that users will not accidentally change any of the formulas.
Update:
Since Column C can have duplicates, need to use the following array formula:
=IF(ISERROR(MATCH(1,(A1=$C:$C)*(B1=$D:$D),0)),"Load number not found","Load number found")
When you paste this formula to E1, make sure to press CTRL + Shift + Enter instead of just pressing the Enter key.
If I understand, a conventional solution with formulae is to concatenate your C and D column data and then search that. If you insert a new columnC with:
=D2&E2
copied down to suit you could apply (but say in ColumnF rather than ColumnE) your existing formula with only slight modification:
=IF(ISERROR(MATCH(A1&B1,$C$2:$C$138,0)),"Load number not found","Load number found")
subject to quite what is in which row.

Moving Data between Worksheets based on a key

In both worksheets I have a key in column A. Not all of the key values are in both worksheets.
For each key value in column A of Worksheet 1, I want to find the corresponding key in worksheet 2 and move the data in column B of worksheet 2 into column B of worksheet 1.
I have never programmed a macro so I am completely lost for writing this code.
There is no need for VBA here, Philip.
Try this formula in cell B1 of Sheet1:
=IFERROR(vlookup(A1,Sheet2!A:B,2,false),"")
If you are on XL 2003, then do this:
=IF(ISERROR(vlookup(A1,Sheet2!A:B,2,false)),"",vlookup(A1,Sheet2!A:B,2,false))
Then drag this formula down for the rest of your data in Column A of Sheet1.
NB - Sheet2 is the assumed name of your Worksheet2, you may need to change to fit your needs.
NB2 - you can lookup vlookup in Excel Help (or online) to better understand what it does
Are you sure you need to use a macro for this? It sounds to me like you are using Excel and a simple VLOOKUP formula would do what you need.
A VLOOKUP looks like this: =VLOOKUP(A1,Sheet2!$A:$B,2,FALSE)
Where A1 is your reference cell (in this case you "key" in column A).
Sheet2!$A:$B is the lookup table (in this case columns A and B from the second sheet).
2 is the column number that you want data from, counting from the left (in this case the second column, column B)
FALSE tells the formula to only return values for exact matches. TRUE returns the closest match in the lookup table.