+ Reply to Thread
Results 1 to 24 of 24

Multifile creating from cell values

  1. #1
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Multifile creating from cell values

    Hello,
    I have 3 columns C, D and E.
    I want to export to txt files every content from column E, where is column D Title of the file, and C is folder. I want to do this all automatically via VBA.

    Is it possible?

    Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Multifile creating from cell values

    yes, it is

    Please Login or Register  to view this content.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    I run it. And it asks me To create macro (dialog box), and I click run. And he puts an extra line End Sub. But I dont know where are the folders? Thanks.

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Multifile creating from cell values

    I have done what you asked, advise you on how to take the text to the file. If you dont know how to create macros and assign them, i'd start by looking at that.

  5. #5
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    I think that we are misunderstood. This is a part of the code? I am not IT/ Developer so, any help would be awesome. I need this for work, to be more efficient.

    Thanks again.

  6. #6
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    Did you mean to add just where to save? Something like this:
    Please Login or Register  to view this content.
    ?

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multifile creating from cell values

    Please Login or Register  to view this content.
    That will never work: "c" and "d" are not range references.

    Can you post a few lines from the workbook (or attach a workbook with sensitive data removed) and explain in context what you want to happen?
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Multifile creating from cell values

    No, you said that the folder was in column c and the filename was in range d, so that is what i have done, so for row 1 it would be => range("c1").text & "\" & range("d1").text

  9. #9
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    HTML Code: 
    I didnt know how to attach the file so here it is, on dropbox.

    Ok, I will mention it again. Column C is the name of the folder. (62 or 64 folders it would be). Column D would be the .txt filename. And column E should be in the .txt file.
    If I was not clear enough just tell me.

    Thanks

  10. #10
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    HTML Code: 
    so, the folder name can contains multiple files (associete.txt) and in this file it shall be written: Hello world
    thanks

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multifile creating from cell values

    A
    B
    C
    D
    E
    1
    100106
    CCHBC
    Associete
    Hello world


    So "Hello World" should be written to C:\CCHBC\Associete.txt?

  12. #12
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    @shg
    Exactly!

  13. #13
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    @nathansav
    I ve tried C1.text..but this is an error "outside procedure"...

  14. #14
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Multifile creating from cell values

    Have you put it in a procedure a sub or function?

  15. #15
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    This is the code. Is it ok?

    Please Login or Register  to view this content.

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multifile creating from cell values

    Untested:

    Please Login or Register  to view this content.
    The directory must exist. The files will be created if they don't exist, and overwritten if they do.

  17. #17
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    This is the code. Is it ok?

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    @shg thank you very much. But there's some problem. "run-time error 76"
    Path not found?
    So, I must create folder? With witch name?
    your code: sPath = "C:\" & .Range("C1").Value & "\"

    maybe: sPath = "C:\" & .Range("C1").Value & "\
    without " at the end?

  19. #19
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    @shg thank you very much.

    But there is just first row with C,D and E values.
    I need for whole sheet maybe just to put while or for loop?

    Again, it's seem to work, but for only one row.
    Thanks.

    I have also put all the "future folders" (from C column) on C:/ And still I am getting error-code 76 regarding on this line of code
    Please Login or Register  to view this content.
    @shg, it's working for some folders, and for the other it doesnt. and it doesnt create all files, just copule of them. I will keep checking in debug mode..it's a partial program I guess :D Thanks on your effort!
    Last edited by cvelle89; 08-04-2014 at 09:57 AM. Reason: Additional information

  20. #20
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multifile creating from cell values

    Please Login or Register  to view this content.
    The name of the directory you want to put the file in, I reckon:

    Please Login or Register  to view this content.

  21. #21
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Multifile creating from cell values

    No, you need to put it in a function, that you will call. I think you should read about macros & procedures first off.

  22. #22
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    @shg
    Ok I have all the folders, and he filled in just a half in only one folder and that's it. still getting error 76

  23. #23
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Multifile creating from cell values

    Error on what line? What was in the cells when it happened? You would be helping yourself if you would be a little more descriptive.

    Spend some time reading http://www.cpearson.com/excel/DebuggingVBA.aspx and then we'll talk some more.

  24. #24
    Registered User
    Join Date
    08-04-2014
    Location
    bg
    MS-Off Ver
    MS Office 2007
    Posts
    71

    Re: Multifile creating from cell values

    Hello. I now see that mz replay didnt reach you.
    So, the main problem was that "future" filename had char "/" in the name, because of that program was crushing.
    When I did some exchanges (/ replaced with -) program created all ok.
    Just one quick question. I noticed that in excel I have some unicode text (example:š đ č ć ). So, is there some line of code that all the .txt files saves as unicode format or UTF-8?

    Thank you very much.
    You are very polite.

+ 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] Creating folders with name as cell values
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-04-2014, 03:54 PM
  2. creating cell to cell formulas vs just copying values?
    By buckhunt122 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2011, 09:28 PM
  3. Creating worksheets from cell values
    By troth in forum Excel General
    Replies: 13
    Last Post: 07-20-2010, 02:13 PM
  4. Creating a list from a cell's changing values
    By benq in forum Excel General
    Replies: 2
    Last Post: 07-20-2010, 05:22 AM
  5. [SOLVED] Creating a link from cell values
    By Capp in forum Excel General
    Replies: 8
    Last Post: 05-08-2006, 06:15 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