+ Reply to Thread
Results 1 to 11 of 11

Vba code to search folders to find cell value and create hyperlink

  1. #1
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,254

    Vba code to search folders to find cell value and create hyperlink

    Hi All

    I have a worksheet(attached).
    Column B is a long list of different invoice no's....eg TT CCM 001
    I am looking for VBA code to search through my directory and find a pdf file i.e TT CCM 001.pdf and create a hyperlink.
    The problem however is that the Dir has numerous different folders with the pdf's within. So TT CCM 001.pdf is in subfolder Circus Circus
    and all the other pdf's are within there own client subfolder.

    The code must go down the list i.e B4:B141 , search for the corresponding cellvalue pdf and create the hyperlink.

    Any help will be appreciated. I have searched but have not found any coding to assist.

    My Dir is "C:\Users\Steven\Desktop\EZ Stock\Clients"

    Thank you in advance
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Vba code to search folders to find cell value and create hyperlink

    This should do it, the hyperlinks are added to the cells in column B.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 01-27-2016 at 01:34 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,254

    Re: Vba code to search folders to find cell value and create hyperlink

    Hi JBeaucaire

    Fantastic you are a star

  4. #4
    Registered User
    Join Date
    08-10-2016
    Location
    slovenia
    MS-Off Ver
    2016
    Posts
    5

    Re: Vba code to search folders to find cell value and create hyperlink

    Hello im new to the VBA macro.

    This code is what im search both one litle thing. I wont in the hyperlink phat is \\192.168.150.6\My Scans\12345.pdf and noth C:\Users\Martin\My Scans\12345.pdf it this posible.

    Best Regrads

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Vba code to search folders to find cell value and create hyperlink

    The macro is editable. Sounds like you would be making an edit to the topPath string.

  6. #6
    Registered User
    Join Date
    08-10-2016
    Location
    slovenia
    MS-Off Ver
    2016
    Posts
    5

    Re: Vba code to search folders to find cell value and create hyperlink

    Yes. I must only change #topPATH = "C:\Users\Martin\My Scans\"# to #topPATH = "\\192.168.150.6\My Scans\\#

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Vba code to search folders to find cell value and create hyperlink

    Probably. I don't work with addressing schemes like that, but in theory it should work, as long as you're not really adding those # like you showed above.

  8. #8
    Registered User
    Join Date
    08-10-2016
    Location
    slovenia
    MS-Off Ver
    2016
    Posts
    5

    Re: Vba code to search folders to find cell value and create hyperlink

    THX for help its work.

  9. #9
    Registered User
    Join Date
    08-10-2016
    Location
    slovenia
    MS-Off Ver
    2016
    Posts
    5

    Re: Vba code to search folders to find cell value and create hyperlink

    Hello

    Again me whit a new question , in the attached image is how I use the macro , my suggestion is that the hyperlink be created in the row C and the name will be the same as is.

    Please Login or Register  to view this content.
    Excel_macro.PNG

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Vba code to search folders to find cell value and create hyperlink

    This one tweak might do that:
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    08-10-2016
    Location
    slovenia
    MS-Off Ver
    2016
    Posts
    5

    Re: Vba code to search folders to find cell value and create hyperlink

    Sorry for my late replay was out of Town. Yes yours change works perfect.

    THX

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Code to create Folders and sub folders based on variable cell values
    By maxwell13 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-03-2015, 09:28 PM
  2. Macro to find a word in a cell, create a transparent text zone over it, create a hyperlink
    By martin brandl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2015, 03:24 PM
  3. Hyperlink to a website search- inserting code to reference one cell.
    By taidog12 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-14-2014, 05:09 PM
  4. Search Folders And Create Hyperlinks To Files
    By hate0lif3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2014, 05:17 AM
  5. [SOLVED] Automatically create hyperlink in active cell when creating folders
    By XxCMoneyxX in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-06-2013, 12:04 PM
  6. Create hyperlink to folders based on values in col A
    By Biinge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-03-2012, 03:35 PM
  7. search folders and create hyperlinks to files
    By slipperyjim in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2009, 07:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1