Hi,
I am downloading order information from my webstore as a .csv then using a macro to reformat it by sending it to another workbook which I then use to upload the orders to my delivery software. I have to do this to make the field headings correct for the upload.
The address fields in G2:M2 need to be merged so that the address is in one field or I only upload the first line.
I can get the address cells to merge, but only the first row. But am struggling to get the right code to make the cell merge function loop through all of the rows, can someone please help? I will have a different number of rows each week so would need the code to be .lastRow, or .xlEnd I believe etc.
Here's my code, it may be basic but it works, I just need a loop to make the macro look at how many rows there are, merge cells G:M for each row and then send the information to my upload page.
Many thanks for the help.
I am downloading order information from my webstore as a .csv then using a macro to reformat it by sending it to another workbook which I then use to upload the orders to my delivery software. I have to do this to make the field headings correct for the upload.
The address fields in G2:M2 need to be merged so that the address is in one field or I only upload the first line.
I can get the address cells to merge, but only the first row. But am struggling to get the right code to make the cell merge function loop through all of the rows, can someone please help? I will have a different number of rows each week so would need the code to be .lastRow, or .xlEnd I believe etc.
Here's my code, it may be basic but it works, I just need a loop to make the macro look at how many rows there are, merge cells G:M for each row and then send the information to my upload page.
Many thanks for the help.
Code:
Sub vegBoxOrderExport()
'
' vegBoxOrderExport Macro
'
Range("G2:N2").Select
Dim outputText As String
Const delim = " " This bit selects address fields and merge
On Error Resume Next (this could be chandoo code. if it is
For Each cell In Selection thanks)
outputText = outputText & cell.Value & delim
Next cell
With Selection
.Clear
.Cells(1).Value = outputText
.Merge
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
End With
Range("A2:P2").Select
Selection.Copy This bit selects the whole data
Application.CutCopyMode = False page and sends it to uploadsheet
Range("A2:P49").Select
Selection.Copy
Windows("ORDERUPLOAD.xlsx").Activate
Range("A2").Select
ActiveSheet.Paste
End Sub
Attachments
Last edited by a moderator: