Export CSV; first three rows contain record map

D

DW

Hello All

I have a situation where I have a worksheet with rows of data to
export to a CSV file using VBA. Simple enough. Now for the kicker.
The first three rows are record maps ending with a "+" and I need to
parse them to Row1 = 10 records, Row2 = 5 records and Row3 = 10
records while the data in the remaining rows will contain 50 records.

i.e. csv output now:

Name,Date,,,,,,,,,+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
GL,,,,,+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Location,State,,,,,,,,,+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
data,data,data,data,data,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
data,data,data,data,data,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
data,data,data,data,data,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,


desired csv output:

Name,Date,,,,,,,,,+
GL,,,,,+
Location,State,,,,,,,,,+
data,data,data,data,data,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
data,data,data,data,data,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
data,data,data,data,data,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

I am trying to avoid manual edit of csv file after export; dealing
with a repetitive process with multiple files.

Any suggestions?

Thanks in advance
DW
 
T

Tom Ogilvy

You can try adding code like this.

for each rw in Range(1:3).rows
for each cell in rw.cells
if cell.Value = "+" then
Range(cell.offset(0,1),cells(cell.row,256)).ClearContents
exit for
end if
Next
Next
' no export the CSV
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top