VBA insert hyperlink in an excel file

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
890
Hi to all of you!
Please note that i have a folder name "EMPLOYEES DETAILS" which contains an excel file EMPLOYEES SUMMARY 2023.xlsx and for each employee it's file e.g. EMPLOYEE 60201356 25/03/23.xlsx. I am kindly require to provide me a support so that to run a VBA code, which should check through col. "J" in file EMPLOYEES SUMMARY 2023.xlsx and if is blank, should place as hyperlink the employees personal details EMPLOYEE 60201356 25/03/23.xlsx if match the name and date of employment in col. "B". I present below an extract of original data in schedule 1. and the expected result in schedule 2.
Thank you all in advance!

Schedule 1.
1703832478952.png



Schedule 2.
1703832518310.png
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi to all of you!
Please note that i have a folder name "EMPLOYEES DETAILS" which contains an excel file EMPLOYEES SUMMARY 2023.xlsx and for each employee it's file e.g. EMPLOYEE 60201356 25/03/23.xlsx. I am kindly require to provide me a support so that to run a VBA code, which should check through col. "J" in file EMPLOYEES SUMMARY 2023.xlsx and if is blank, should place as hyperlink the employees personal details EMPLOYEE 60201356 25/03/23.xlsx if match the name and date of employment in col. "B". I present below an extract of original data in schedule 1. and the expected result in schedule 2.
Thank you all in advance!

Schedule 1.
View attachment 104088


Schedule 2.
View attachment 104089
Ello Panoos64,

To help improve your chances of getting help in this forum, do the following:

Use this forums Excel Add-in to simplify sharing your sample data; it's located here. There also a link to it in the default reply window at the bottom of any thread:


1705207777692.png


Update your profile to include your Office Version, Power Tools (if applicable) and OS Platform:

1705207834054.png


To update your profile, just click on your profile name at the top and you'll see those options available to you.

I'm in the process of providing a potential solution now. Just verifying a few things first before posting it.
 
Upvote 1
Hi to all of you!
Please note that i have a folder name "EMPLOYEES DETAILS" which contains an excel file EMPLOYEES SUMMARY 2023.xlsx and for each employee it's file e.g. EMPLOYEE 60201356 25/03/23.xlsx. I am kindly require to provide me a support so that to run a VBA code, which should check through col. "J" in file EMPLOYEES SUMMARY 2023.xlsx and if is blank, should place as hyperlink the employees personal details EMPLOYEE 60201356 25/03/23.xlsx if match the name and date of employment in col. "B". I present below an extract of original data in schedule 1. and the expected result in schedule 2.
Thank you all in advance!

Schedule 1.
View attachment 104088


Schedule 2.
View attachment 104089
Ello Panoos64,

I'm not sure which version of Office you're using, so I'm providing two options:

Column C is using TEXTJOIN (O365) and Column D is using CONCAT (all versions) to combine the cell values.

TEXTJOIN or CONCAT are combining string values and cell values of Column B & A.
TEXT is converting the DATE to TEXT using a 'yyyy-mm-dd' FORMAT. Windows doesn't allow slashes "/" in file or folder names as seen in your example.
The two STRINGS being combined are a sample file path "C:\Employee Files\" at the beginning and the ".xlsx" file extension.

Once all of the above are displayed correctly and we see a full path to the file, we can then wrap all that up in the HYPERLINK Function.
You can add a friendly name as well for the hyperlink, so I used:

TEXTJOIN(,TRUE,B3," ",TEXT(A3,"yyyy-mm-dd"),".xlsx")
CONCAT(B3," ",TEXT(A3,"yyyy-mm-dd"),".xlsx")

See below the sheet for the full formula.

I also used a Lastname, Firstname approach, but you obviously want to change anything needed to conform with your standard file naming convention.

If needed, you will likely need to change the date format from yyyy-mm-dd to dd-mm-yyyy as seen in your sample data.

Be sure to make a copy of the Sheet and test it before implementing these changes in your production file.

VBA Testing.xlsm
ABCD
1Requires Office 365Any Office Version
2Date EmployedNameEmployee File using TEXTJOINEmployee File using CONCAT
32023-03-25Lname, Fname 60201356Lname, Fname 60201356 2023-03-25.xlsxLname, Fname 60201356 2023-03-25.xlsx
42023-01-16Lname, Fname 60201408Lname, Fname 60201408 2023-01-16.xlsxLname, Fname 60201408 2023-01-16.xlsx
Hyperlinks
Cell Formulas
RangeFormula
C3:C4C3=HYPERLINK(TEXTJOIN(,TRUE,"C:\Employee Files\",B3," ",TEXT(A3,"yyyy-mm-dd"),".xlsx"),TEXTJOIN(,TRUE,B3," ",TEXT(A3,"yyyy-mm-dd"),".xlsx"))
D3:D4D3=HYPERLINK(CONCAT(B3," ",TEXT(A3,"yyyy-mm-dd"),".xlsx"),CONCAT(B3," ",TEXT(A3,"yyyy-mm-dd"),".xlsx"))
 
Upvote 1
Solution
Thank you zero269! The first formula C3:C4 adapt to my data and works perfect. I use the office 2021 and thank for your advice to update my profile. I was searing for a long time about this project and i appreciated so much that, you resolved my issue. Thank you once again for your time. Have a great day!
 
Upvote 0
Thank you zero269! The first formula C3:C4 adapt to my data and works perfect. I use the office 2021 and thank for your advice to update my profile. I was searing for a long time about this project and i appreciated so much that, you resolved my issue. Thank you once again for your time. Have a great day!
That's great news and I'm glad this worked out for you.
Best regards,
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top