However, there is a problem. If you look at the source file, there may be customers who ordered more than one item. If that is the case ( in my file Yvonne Hell ) the source file has additional rows for the items.
When I run the Macro, it leaves the concerning filed empty, unfortunately.
Can anyone help ?
p.s. both files must not be in the same directory, or else the macro will not run
Re: Problem with Macro to extract data from Source to Output file
Ok, I made it easier to understand. See the 2 new attachments. Download the Source.xls to your desktop ( you might have to change the path ) and the Outfile file with the macro to some other location. Then run the only macro.
Re: Problem with Macro to extract data from Source to Output file
Now I've an important meeting, I have to go to the swimming pool !
It will be easier to understand with a crystal clear explanation with an attachment of expected result,
with that I'm sure you will have more answers …
Re: Problem with Macro to extract data from Source to Output file
Originally Posted by Marc L
As I don't see where in the code the source text file is opened …
And some rows in this text file have column M empty, in particular for Yvonne Hell ‼
That's how Ebay gives us the data. If buyer buy more than one item, first cell is empty and underneath come the item names. Macro shall consolidate those type of entries, e.g. Yvonne Hell bought the three items ...
Re: Problem with Macro to extract data from Source to Output file
Hello !
try yourself, you will find an empty cell in Column F in the Output file. Yes, the Input has an empty cell too, but the Macro should get rid of that, that's the mission Column F may not have any empty cells ....
From source text csv file and according to your post #17 attachment,
at beginner level using the old via romana way :
PHP Code:
Sub Demo() Dim CSV$, R&, SPQ$(), VA$(4), S$(), L& CSV$ = ThisWorkbook.Path & "\Source.csv" If Dir(CSV) = "" Then Beep: Exit Sub Sheet2.UsedRange.Offset(1).ClearContents R = FreeFile Open CSV For Input As #R SPQ = Split(Replace(Input(LOF(R), #R), """", ""), vbCrLf) Close #R L = 1 For R = 3 To UBound(SPQ) - 3 S = Split(SPQ(R), ";") If S(2) > "" Then VA(0) = S(2): VA(2) = S(4) If S(12) > "" Then L = L + 1 VA(4) = S(12) Sheet2.Cells(L, 2).Resize(, 5).Value = VA End If Next End Sub
Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
Re: Problem with Macro to extract data from Source to Output file
Hello Marc,
I like your solution, it is fast and easy, however: it does not add the comments. The comments contain the name, the street name & number, the Zip Code & City, Country and Tel Number. See my code in the very first post.
My code follows exactly your expected result from post #17 :
Originally Posted by elgato74
... it should look like the attached file when the Macro is finished !
In this attachment there are only 3 filled columns ‼
This thread has now a third page but if in your initial post you had joined a source file and
an exact expected result workbook (already just with data without running any "code")
you may have a quality solution from the first answer !
Re: Problem with Macro to extract data from Source to Output file
As required several times, just attach a source csv file and an exact expected result according to this source file !
If at least a true explanation was in the initial post explaining the output layout …
Should we guess ? Of course not ‼
No effort on your side ? Why would we do some then ?!
As answers are at level of initial presentation, the better initial post, the better and quick solution …
Re: Problem with Macro to extract data from Source to Output file
Within my code at beginner level, during execution in step-by-step mode or via a break-point
see within Locals window in S variable in which index (column) data are …
alerte2.gif I do not know why but within your workbook the markers of inside cells comments were not visible !
As I can't see those markers, I can not understand as it is very not difficult to explain
you do not expect visible texts in a Comments column but hidden within cells !
Mod is at beginner level, just needing to warm a couple of brain neurons !
I can't see a glitch but tell me in case of any :
PHP Code:
Sub Demo4Noobs() Dim C$, R&, SPQ$(), L&, S$(), VA$(4) C$ = ThisWorkbook.Path & "\Source.csv" If Dir(C) = "" Then Beep: Exit Sub With Sheet2.UsedRange.Offset(1): .ClearComments: .ClearContents: End With R = FreeFile Open C For Input As #R SPQ = Split(Replace(Input(LOF(R), #R), """", ""), vbCrLf) Close #R L = 1 For R = 3 To UBound(SPQ) - 3 S = Split(SPQ(R), ";") If S(2) > "" Then VA(0) = S(2) VA(2) = S(4) C = Join(Array(S(2), S(5), S(9) & " " & S(7), S(10), "Tel. " & S(3)), vbLf) End If If S(12) > "" Then L = L + 1 VA(4) = S(12) With Sheet2.Cells(L, 2) .Resize(, 5).Value = VA .AddComment .Comment.Text C End With End If Next End Sub
fleche.gif Do you like it ? So thanks to click on bottom left star icon « ★ Add Reputation » !
Bookmarks