ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Inseart row if cell number is repeating (https://www.excelbanter.com/excel-discussion-misc-queries/201258-inseart-row-if-cell-number-repeating.html)

JoeM[_2_]

Inseart row if cell number is repeating
 
Hi

I have a data sheet, which is a sales data which contains item
particulars. each invoice contains one or more items. many of them is
single item which ends in single row. if more items are there, it
comes in different rows. i want to inseart one row each if the invoice
number is repeating to two three up to 20 rows. new row need to come
top of the cell number

1 rice 10 kg
27.00 270.00
2 oil 3 kl
80-00 240.00
3 Rice 5 kg
33.00 165.00
3 oil 1 kl
80.00 80.00
4 Salt 1 kg
10.00 10.00


the invoce number (cell number) "first column" 3 is repeating twice.

1 rice 10 kg
27.00 270.00
2 oil 3 kl
80-00 240.00

3 Rice 5 kg
33.00 165.00
3 oil 1 kl
80.00 80.00
4 Salt 1 kg
10.00 10.00


i insearted one row after cell number 2, anyonce can help to creat
one macro for this?(Inseart row with condition)


thanks

Jophy





Bob Phillips[_3_]

Inseart row if cell number is repeating
 
Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long

Application.ScreenUpdating = False

With ActiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = LastRow - 2 To 2 Step -1

If .Cells(i, "A").Value < .Cells(i + 1, "A").Value And _
.Cells(i + 1, "A").Value = .Cells(i + 2, "A").Value Then

.Rows(i + 1).Insert
End If
Next i
End With

Application.ScreenUpdating = True

End Sub


--
__________________________________
HTH

Bob

"JoeM" wrote in message
...
Hi

I have a data sheet, which is a sales data which contains item
particulars. each invoice contains one or more items. many of them is
single item which ends in single row. if more items are there, it
comes in different rows. i want to inseart one row each if the invoice
number is repeating to two three up to 20 rows. new row need to come
top of the cell number

1 rice 10 kg
27.00 270.00
2 oil 3 kl
80-00 240.00
3 Rice 5 kg
33.00 165.00
3 oil 1 kl
80.00 80.00
4 Salt 1 kg
10.00 10.00


the invoce number (cell number) "first column" 3 is repeating twice.

1 rice 10 kg
27.00 270.00
2 oil 3 kl
80-00 240.00

3 Rice 5 kg
33.00 165.00
3 oil 1 kl
80.00 80.00
4 Salt 1 kg
10.00 10.00


i insearted one row after cell number 2, anyonce can help to creat
one macro for this?(Inseart row with condition)


thanks

Jophy







JoeM[_2_]

Inseart row if cell number is repeating
 
Thanks bob its fantastic

god bless you


jophy


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

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