Hi,
Have got a CSV file of religious verse, with each verse in a new row, verses separated by a blank cell:
Verse 1
abcdef
abcdefg
abcdefgh
Verse 2
abcdef
abdefg
abcdefgh
I need to import it into a database for use by an Android app, but the CSV has to be in the format of:
Tag Value
1 a,b,c
2 d,e,f
and so on.
Is it possible for a concatenate VBA function that will concatenate the rows, using a comma delimiter, but when a blank cell is encountered, to create concatenate the subsequent cells into a new row, so that it looks as per the Tag/Value combination above please?
I've looked at a few Concatenate VBA functions on here but haven't got figured out how to do it yet beyond manual range selection!
Thanks in advance!
It would be easier to help you if you uploaded a dummy workbook, containing data in the same structure.
With a sheet of the desired outcome.
Steffen
Use Text To Columns, Fixed Width option.
Ok sample csv file posted. The left is the text, the right is an example of how ideally it would be set out. Any assistance much appreciated! Thanks.
Hi,
Try this code
Sub steffen() Dim verse As String Dim sText For Each cell In Range("A1:A" & Range("A60000").End(xlUp).Row) If InStr(cell.Text, "Verse") > 0 Then sText = Application.WorksheetFunction.Transpose(Range("A" & cell.Row).Resize(Range("A" & cell.Row).CurrentRegion.Rows.Count)) For i = 1 To UBound(sText) On Error Resume Next verse = verse & sText(i) & "," Next i Else ' Do nothing End If Range("D60000").End(xlUp).Offset(1, 0) = verse verse = "" Next cell End Sub
Take a look at the file
To thank someone who has helped you, click on the star icon below their name.
I hate reading
Portfolio
I need a job.I am young and incompetent
Thanks Steffen, that worked perfectly!
JieJenn, thank you also for your efforts. Unfortunately it didn't contain a delimiter, which is crucial for Google App Engine to process the content properly.
Thanks very much indeed both! Now I'm going to go through the code and work out how you did it!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks