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!
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!
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
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.
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.
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.
Did you mean to add just where to save? Something like this:
?Please Login or Register to view this content.
That will never work: "c" and "d" are not range references.Please Login or Register to view this content.
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
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
I didnt know how to attach the file so here it is, on dropbox.HTML Code:
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
so, the folder name can contains multiple files (associete.txt) and in this file it shall be written: Hello worldHTML Code:
thanks
A B C D E 1 100106 CCHBC AssocieteHello world
So "Hello World" should be written to C:\CCHBC\Associete.txt?
@shg
Exactly!
@nathansav
I ve tried C1.text..but this is an error "outside procedure"...
Have you put it in a procedure a sub or function?
This is the code. Is it ok?
Please Login or Register to view this content.
Untested:
The directory must exist. The files will be created if they don't exist, and overwritten if they do.Please Login or Register to view this content.
This is the code. Is it ok?
Please Login or Register to view this content.
@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?
@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@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!Please Login or Register to view this content.
Last edited by cvelle89; 08-04-2014 at 09:57 AM. Reason: Additional information
The name of the directory you want to put the file in, I reckon:Please Login or Register to view this content.
Please Login or Register to view this content.
No, you need to put it in a function, that you will call. I think you should read about macros & procedures first off.
@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
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.
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks