Hyperlink after Vlookup - vba

This simple thing is eating my brain out. Here is the challenge:
I have 2 sheets in the same workbook. Say Sheet 1 and Sheet 2. I want to Vlookup for the value present in Sheet 1 Column A and Sheet 2 column B. If the value is found i want to put a hyperlink in Sheet 1 Column A to point it to Sheet 2 Column D. In simple words, there are program names present in both the sheets and associated risk in sheet 2. If the program is present in both the sheets then i want to navigate directly to the risk present in the Sheet 2 upon clicking the program name in Sheet1.
I am attaching the sample file with this thread. Please somebody help me. I have tried with vba and normal formulas. Nothing is being worked out.
SAmple file can be downloaded from here

Here's how you can do that with a formula. You'll need to change the workbook name in the HYPERLINK formula to match yours.
=IF(ISERROR(VLOOKUP($A1,Sheet2!$B:$B,1,0)),"",HYPERLINK("[StackTest.xlsx]'Sheet2'!D"&TEXT(MATCH($A1,Sheet2!$B:$B,0),"#"),"Click Here"))

Related

Auto populating rows from another sheet conditional to a specific cell value

Hello i am trying to autopopulate rows from another sheet if a specific value if found in a specific cell. So far, i managed to do it manually by adding this line in Sheet #2 for each cell.
=IF(OR('Le 2250'!$C48="Nouveau locataire",'Le 2250'!$C48="Décès", 'Le 2250'!$C48="Retention"), 'Le 2250'!$B48,"")
I am trying to create a vba script that will generate each column in Sheet#2, and that will dynamically update regarding if i add a row in Sheet 1 or delete it.
Sheet1 is:
Sheet2 is:
Your help is appreciated
What your looking for is the INDIRECT function
As an example:
=CELL("contents",INDIRECT("Sheet1!B5"))
This always pick up the value in Sheet1 Cell B5, regardless of changes in Sheet1.
For more information: Excel INDIRECT Function
Edit: To directly answer the question with INDIRECT.
=IF(OR(INDIRECT("'Le 2250'!C48")="Nouveau locataire",INDIRECT("'Le 2250'!C48")="Décès"),CELL("contents",INDIRECT("'Le 2250'!B48")),"")

VBA for removing duplicates in a specific column in another tab

this is a simple issue with simple VBA but I have not been able to find the answer through multiple searches.
I want to be able to remove duplicates in a column A in Sheet 2 of my workbook by pressing a button assigned to the macro in Sheet 1.
This is the code I have assigned to the button in Sheet 1:
Sub RemoveDupes()
Sheets("Sheet2").Range("A1:A10350").RemoveDuplicates
End Sub
This code seems to just try to remove duplicates in the column in which the button exists or whatever column in whatever sheet I have clicked on. How do I specify to remove duplicates in column A in Sheet 2?

Replace reference in formula with precedent

I have an excel file with three sheets (1,2,3), in the first sheet are primary data, in the third sheet are final data for output and the second sheet is bridge between them. I need to update formulas in the third sheet so I can delete the second sheet.
For example, there is value in sheet "1" in cell A1, then in sheet "2" is C5='1'!A1, in sheet "3" B4='2'!C5, and I need to get in sheet "3" B4='1'!A1. I need to do this for thousands of cells, therefore it is impossible to do it manually and I was thinking about using macro, but I was unable to create such macro. Can somebody help me?
This question raised because the bridge in sheet "2" is complex and not only assign one value from sheet "1" to one cell but it also add up several cells from sheet "1" together, therefore there is not any simple way to replace the bridge by vlookup or similar function.
It's pretty difficult to answer this question the way you have written it. This is because it seems all the cells in Sheet3 point to a "random" spot in sheet 2. If there is no rhyme or reason to how sheet pulls its numbers, replacing the formulas could be hard. However, try this:
If sheet 3 cells only EVER refers to a single cell in sheet 2, and sheet to only EVER refers to sheet 1, then you can go to sheet 2, and press CTRL + H. This will bring up the "find and replace" function. Replace all instances of "=" with "ZZZZ=". When you look to sheet3, you will see that instead of giving the values calculated off of sheet1 through sheet 2, a cell in sheet3 could say something like "ZZZZ='sheet1'!A1+'sheet1'!B1", because that's the value of sheet 2 that it points at. From there, copy and paste all of sheet3 to values only. Then, CTRL + H again and replace all instances in sheet of "ZZZZ=" with "=".
However I doubt this will work as if sheet2 contains values used elsewhere in sheet2 to calculate, or if sheet3 refers to things in other ways, this will fall apart.

I need to generate new workbooks using existing sheets that I will autopop with data

I have two sheets on my template. Sheet one contains a SKU in column A and a descr. in column B
On sheet 2, I have a pre-written template that has generic SKU and Description. That means under the item sku, it says D999 and under the description it says xxx.
I want to replace "999" with the value in A2 on my first sheet, but the 999 is in multiple columns through the sheet. Next, I want to replace the "xxx" with the data in B2 from sheet 1. I can't seem to find a VBA code that will do this specifically.
Lastly, once the find and replaces are done, I need to have it save me a new workbook using sheet2, in the same format, and name it as the value in A4 on sheet 2. I think you should be able to find the workbook here My Workbook
Basically, I want to be able to enter a bulk amount of new SKUs and Description, and be able to generate a new workbook for each SKU I enter. Right now I have 78 waiting to have sheets made.
In the cell to the right of the cells where you want to type in the SKU, add the following formula: =Match(A2, LookupsheetName!B:B,0). This will return the row the SKU was found on. In the next cell to the right use the Index function: =Index(LookupSheetName!A1:B1000, B2, 0). This will bring the label in column B to the current page. The Match function locates the row the SKU was found on.
Try these for looking up the information, because they are more efficient than VLookups.
The code for copying a worksheet to another workbook can be created using the Macro recorder on the Developer tab. Turn the recorder on then do the steps to manually move/copy to another workbook. When done, open the VBA editor and figure out how to save the workbook to a new name each time.
Good luck.

Excel How to hyperlink to filtered data

I have more than 2 sheets in an excel file, where one sheet (A) has the data that I want to filter. In other sheets, I want to have a hyperlink each that when clicked, will link to sheet A which is displaying the filtered data according to that sheet.
for example, in Sheet A, I have the following data
A - apple
B - book
C - cat
A - angel
B - bread
In another sheet, i have a hyperlink to filtered data "A" so when it is clicked, sheet A will display:
A - apple
A - angel
In another sheet, it will show filtered data in sheet A when clicked on the hyperlink:
B - book
B - bread
I heard about VBA but I have no idea on it. Is there another simpler way to do this without using VBA? If not, can you give me a guideline on the VBA for this?
You can indeed do this using VBA. Your best bet as a VBA beginner is to:
Use the record macro functionality, and then
Create a button (I don't think you can create a hyperlink to a macro) which executes the desired macro
I did this for your first example (5 lines of data, I added a header) and the resulting VBA code was as follows:
ActiveSheet.Range("$A$1:$B$6").AutoFilter Field:=1, Criteria1:="A"