VBA code to open .pdf's saved in different folder locations

MrJee91

New Member
Joined
Jul 16, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Looking for some help creating a VBA code or IF function that will open a .pdf based on values within 2 different cells.

For instance Column F can have a range of Chapter numbers e.g 32, 52, 55 etc. which relate to specific folder names saved on a drive (for this example: my desktop)

I.E

C:\Users\(USERNAME)\Desktop\32
C:\Users\(USERNAME)\Desktop\52
C:\Users\(USERNAME)\Desktop\55

Column M has .pdf file names such as

Chapter32_drawing1.pdf
Chapter32_drawing2.pdf

Chapter52_drawing1.pdf
Chapter52_drawing2.pdf

Essentially I want to create a hyperlink in Column N, that will find a specific (Chapter) folder based on the value of Column F, and return the file name based on information in column M.

Cell F2 = 32 + Cell M2 = Folder 32 + Chapter32_drawing1.pdf
Cell F3 = 52 + Cell M3 = Folder 52 + Chapter52_drawing1.pdf

Then the N Column hyperlink automatically opens the .pdf

N2 = C:\Users\(USERNAME)\Desktop\32\Chapter32_drawing1.pdf

N3 = C:\Users\(USERNAME)\Desktop\52\Chapter52_drawing1.pdf

The Chapter folders need to exist for the sake of organising the drawings inside them, I know this would be much simpler if all the drawings were in one Folder.

Any help would be amazing!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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