+ Reply to Thread
Results 1 to 9 of 9

Excel Vba Loop List

  1. #1
    Forum Contributor
    Join Date
    01-09-2011
    Location
    Nomans, Land
    MS-Off Ver
    Excel 2007
    Posts
    103

    Excel Vba Loop List

    Dear experts

    I have a list of values in Column A that I want to loop through using this code and save as a text file.

    I've managed to write the code below to run one value at a time and modifying it manually. So, I have to keep changing the "i.value = CE" and the "FileName", respectively everytime, which is madness when you have to do this more than 50 times.

    I've attached a sample workbook with the module for testing.

    Any help would be much appreciated
    Thank you


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by exc4libur; 09-09-2016 at 10:07 AM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Excel Vba Loop List

    The code does not appear to work. I do not think downloading a file is that simple, but if you want to loop through each cell in column A where the "CE" comes from column A while the file name comes from column B.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-09-2011
    Location
    Nomans, Land
    MS-Off Ver
    Excel 2007
    Posts
    103

    Re: Excel Vba Loop List

    Quote Originally Posted by AB33 View Post
    The code does not appear to work. I do not think downloading a file is that simple, but if you want to loop through each cell in column A where the "CE" comes from column A while the file name comes from column B.
    Hi AB33, thank you for replying. I have attached a sample workbook with the code working on the main thread. You have to activate HTML and Internet references.

    Also, I tried your code and I didn't manage.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Excel Vba Loop List

    Okay,
    It seems the data are the HTML body. I thought you are downloading a file.
    My code works, but there is an issue with column B.
    The code will error if the file names do not exist. Do you have the file names for all rows on column B?

  5. #5
    Forum Contributor
    Join Date
    01-09-2011
    Location
    Nomans, Land
    MS-Off Ver
    Excel 2007
    Posts
    103

    Re: Excel Vba Loop List

    Quote Originally Posted by AB33 View Post
    Okay,
    It seems the data are the HTML body. I thought you are downloading a file.
    My code works, but there is an issue with column B.
    The code will error if the file names do not exist. Do you have the file names for all rows on column B?
    When you refer to the file names, do you mean the full path ie. "C:\test\file.txt" or just the file name "file.txt".

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Excel Vba Loop List

    C:\test\file.txt

    C:\test\ is the directory or folder name
    and file.txt is the file name

  7. #7
    Forum Contributor
    Join Date
    01-09-2011
    Location
    Nomans, Land
    MS-Off Ver
    Excel 2007
    Posts
    103

    Re: Excel Vba Loop List

    Quote Originally Posted by AB33 View Post
    C:\test\file.txt

    C:\test\ is the directory or folder name
    and file.txt is the file name
    i have the file names for all rows in column b.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Excel Vba Loop List

    Forget column B.
    These code will create the folder for each cell in column A. If the folder exists, it simply overwrites it.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    01-09-2011
    Location
    Nomans, Land
    MS-Off Ver
    Excel 2007
    Posts
    103

    Re: Excel Vba Loop List

    HAAA!! Saved me, works perfectly. Thank you!

+ 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] VBA loop through list
    By neilkotze in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-10-2015, 10:08 AM
  2. Replies: 0
    Last Post: 05-24-2015, 09:17 AM
  3. [SOLVED] loop through selection in list box
    By Code Flunkie in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-03-2014, 02:20 PM
  4. [SOLVED] Loop within loop confuses excel... and me.
    By Ataraxicatom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2014, 10:23 AM
  5. Loop in list and fill in other list
    By theconscience in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-31-2013, 04:33 AM
  6. Help with loop for creating list in excel
    By DrSpliff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-07-2011, 07:10 AM
  7. Excel Loop Macro - find text and copy to form new list
    By twinkle001 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2010, 02:41 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