ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Creating a macro commad to shift selected rows to the right next c (https://www.excelbanter.com/excel-discussion-misc-queries/45466-creating-macro-commad-shift-selected-rows-right-next-c.html)

Shifting of Multiple Row to the right

Creating a macro commad to shift selected rows to the right next c
 
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.

Rowan

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

Shifting of Multiple Row to the right wrote:
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.



All times are GMT +1. The time now is 05:06 AM.

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