scriptebay
New Member
- Joined
- Feb 24, 2011
- Messages
- 1
There are 2 parts of the csv file which I am working on. Part 1 to delete particular columns is completed. What I need help is
# How to wrap & merge information from different column/rows
# run as single script
Part 1 completed
Part 2 where I need help is that the name and address are in different columns
Buyer Fullname|Buyer Address 1|Buyer Address 2|Buyer City|Buyer State|Buyer Zip|Buyer Country
current information looks like
XYZ WXY 162 robert dr ladson sc 29456 United States
The way I want is that the macro should compile the information either as
Buyer Fullname
Buyer Address 1
Buyer Address 2
Buyer City Buyer State Buyer Zip
Buyer Country
example
XYZ WXY
162 robert dr
ladson sc 29456
United States
Note: one check has to be that if "Buyer Address 2" is empty then it should ignore.
Part 3 - I would need to make this as single script which will delete the columns and merge address
Appreciate if anyone can help.
# How to wrap & merge information from different column/rows
# run as single script
Part 1 completed
Code:
Sub Deletecolumns()
'Find last column with data in Row 1
v = Array("Item Number", "Item Title")
lastCol = Cells(1, Columns.Count).End(xlToLeft).Column
'Loop through columns, starting at the last one
For delCol = lastCol To 1 Step -1
'Delete columns with specific Name in Row 1
bFound = False
For i = LBound(v) To UBound(v)
If InStr(1, Cells(1, delCol), v(i), vbTextCompare) And _
Len(Cells(1, delCol)) = Len(v(i)) Then
bFound = True
Exit For
End If
Next i
If bFound Then _
Cells(1, delCol).EntireColumn.Delete
Next delCol
End Sub
Part 2 where I need help is that the name and address are in different columns
Buyer Fullname|Buyer Address 1|Buyer Address 2|Buyer City|Buyer State|Buyer Zip|Buyer Country
current information looks like
XYZ WXY 162 robert dr ladson sc 29456 United States
The way I want is that the macro should compile the information either as
Buyer Fullname
Buyer Address 1
Buyer Address 2
Buyer City Buyer State Buyer Zip
Buyer Country
example
XYZ WXY
162 robert dr
ladson sc 29456
United States
Note: one check has to be that if "Buyer Address 2" is empty then it should ignore.
Part 3 - I would need to make this as single script which will delete the columns and merge address
Appreciate if anyone can help.