+ Reply to Thread
Results 1 to 9 of 9

Copy windows folder contents as a link and insert into worksheet

  1. #1
    Registered User
    Join Date
    06-04-2014
    Location
    Newcastle, Australia
    MS-Off Ver
    2010
    Posts
    63

    Copy windows folder contents as a link and insert into worksheet

    Hi

    I am learning VBA as I go and whilst I have done a search I couldn't find a solution.

    I need to copy a windows folder contents filenames into a worksheet.

    Presently I navigate to the folder I need to copy from, do a SELECT ALL, SHIFT and RIGHT CLICK, COPY AS PATH and PASTE VALUES it into the worksheet.

    Is this something that VBA could perform or do I need to look for other means.

    Any clues or help would be greatly appreciated.

    TIA, Anthony
    Last edited by robbo1172; 08-13-2018 at 03:56 AM. Reason: Added FILENAMES to WINDOWS FOLDER CONTENTS for clarity

  2. #2
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Copy windows folder contents as a link and insert into worksheet

    Check https://stackoverflow.com/questions/...lder-using-vba
    Teach me Excel VBA

  3. #3
    Registered User
    Join Date
    06-04-2014
    Location
    Newcastle, Australia
    MS-Off Ver
    2010
    Posts
    63
    Thanks for the link. I’ll give it a go tomorrow. Much appreciated.

    Anthony

  4. #4
    Registered User
    Join Date
    06-04-2014
    Location
    Newcastle, Australia
    MS-Off Ver
    2010
    Posts
    63

    Re: Copy windows folder contents as a link and insert into worksheet

    I have assembled the following code (I am still in the very early stages of learning VBA) which will retrieve the first file name and output to cell A1, but that is all. If there are 10 file names in the folder, cells A1 to A10 should all have file names in them. Could someone please point me in the right direction.

    Thanks

    Please Login or Register  to view this content.
    Thanks in advance

  5. #5
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Copy windows folder contents as a link and insert into worksheet

    try this

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Copy windows folder contents as a link and insert into worksheet

    This should also work

    Please Login or Register  to view this content.

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Copy windows folder contents as a link and insert into worksheet

    Quote Originally Posted by robbo1172 View Post
    I have assembled the following code ...
    Just a typo. This line:

    Please Login or Register  to view this content.
    should be:

    Please Login or Register  to view this content.
    since you're using Counter to determine the output location. Option Explicit is your friend.
    Rory

  8. #8
    Registered User
    Join Date
    06-04-2014
    Location
    Newcastle, Australia
    MS-Off Ver
    2010
    Posts
    63

    Re: Copy windows folder contents as a link and insert into worksheet

    Thank you so much for your help, it works perfectly (I did use the second code that you suggested). Rather than blindly accept and use solutions offered by other people, I like to work through how it was done so I can learn as I go, I really appreciate your very clear notes as to what each part of the code does.

    Once again, thank you my friend

  9. #9
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Copy windows folder contents as a link and insert into worksheet

    Thanks for the feedback and rep+
    Glad to have helped.

+ 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. Replies: 7
    Last Post: 07-18-2017, 11:28 AM
  2. [SOLVED] VBA to link to folder on my network using the contents as a cell as part of the address.
    By Medimatt in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-31-2017, 06:30 AM
  3. Copy hyperlink contents (photos) to a new folder
    By Agrocolo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2016, 08:12 AM
  4. Link excel cell to folder in Windows directory
    By jamesrm in forum Excel General
    Replies: 1
    Last Post: 09-18-2012, 11:42 AM
  5. Replies: 2
    Last Post: 02-22-2012, 11:12 AM
  6. VBA - Insert row, copy contents of original row except for contents of column A
    By Royzer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2012, 07:41 PM
  7. Search a Folder and Copy Contents
    By jacof in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2011, 11:18 AM

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