Creating a macro commad to shift selected rows to the right next c

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

Guest

Pls Help....
The command for cutting and pasting a single row looks likes this

Range("A746:H746").Select
Selection.Cut
Range("B746").Select
ActiveSheet.Paste

There again for another row i need to do the same thing as what i had did
for the pervious.

Range("A748:H748").Select
Selection.Cut
Range("B748").Select
ActiveSheet.Paste
Range("C749").Select

And i had more than hundred thousand of selected rows to be shift to the
right, cause is a data collected from vendor and the complie data is some
thing lke this:-

328 Sales $ 0 0 0 0 0
Qnty 0 0 0 0 0 0 0
509 Sales $ 0 0 0 0 0
Qnty 0 0 0 0 0 0 0

ALEX Sales $ 0 0 0 0 0
Qnty 0 0 0 0 0 0 0
ALJUNIED Sales $ 0 0 0 0 0 0
Qnty 0 0 0 0 0 0 0
ANCH Sales $ 0 0 0 0 0
Qnty 0 0 0 0 0 0 0
ANG Sales $ 0 0 0 0 0 0
Qnty 0 0 0 0 0 0 0

As u can see the qnty is not the same column as the sale column.
Thx a million for your help.
 
You might try something like this which will move each row which has
Qnty in column A one cell to the right.

Sub MoveData()
Dim i As Long
Dim cRange As Range
Dim cell As Range
If Range("A65536").Value <> Empty Then
i = Cells(Rows.Count, 1).End(xlUp).Row
Else
i = 65536
End If
Set cRange = Range(Cells(1, 1), Cells(i, 1))
For Each cell In cRange
If cell.Value = "Qnty" Then
cell.Insert Shift:=xlToRight
End If
Next cell
End Sub

Hope this helps
Rowan
 

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