ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to use VBA to automate sorting, cutting & pasting in Excel? (https://www.excelbanter.com/excel-programming/396891-how-use-vba-automate-sorting-cutting-pasting-excel.html)

FredB

How to use VBA to automate sorting, cutting & pasting in Excel?
 
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

joel

How to use VBA to automate sorting, cutting & pasting in Excel?
 
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

"FredB" wrote:

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


FredB

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

It works a treat!

"Joel" wrote:

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

"FredB" wrote:

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



All times are GMT +1. The time now is 05:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com