How to use VBA to automate sorting, cutting & pasting in Excel?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a list of data (Outstanding Orders to be filled) and I need to cut all
orders for a particular customer and paste them at the end of the list.

Can anyone please help me with the code to do this, I am just a novice at
VBA - but very keen to learn
 
The code below checks column A againstt a customer name and paste the entire
row at the end of the list.

Sub cutandpaste()

Customer = "ABC"

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
RowCount = 1
For LoopCounter = 1 To LastRow
If Cells(RowCount, "A").Value = Customer Then
Rows(RowCount).Cut Destination:=Rows(LastRow + 1)
Rows(RowCount).Delete
Else
RowCount = RowCount + 1
End If
Next LoopCounter


End Sub
 
Thanks Joel

It works a treat!

Joel said:
The code below checks column A againstt a customer name and paste the entire
row at the end of the list.

Sub cutandpaste()

Customer = "ABC"

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
RowCount = 1
For LoopCounter = 1 To LastRow
If Cells(RowCount, "A").Value = Customer Then
Rows(RowCount).Cut Destination:=Rows(LastRow + 1)
Rows(RowCount).Delete
Else
RowCount = RowCount + 1
End If
Next LoopCounter


End Sub
 

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

Back
Top