#1   Report Post  
Esrei
 
Posts: n/a
Default Macro insert lines

This is my macro to insert lines if the value in b chanbes. I want it to
inset 26 lines it only inserts 1 please help

Sub Deilv()
Dim LastRow As Long
Dim row_index As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").EntireRow.insert _
(x24ShiftDown)
End If
Next
End Sub


  #2   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Esrei,

Try:

Sub Deilv()
Dim LastRow As Long
Dim row_index As Long

Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").Resize(26).EntireRow. _
Insert Shift:=xlDown
End If
Next
Application.ScreenUpdating = True
End Sub


---
Regards,
Norman



"Esrei" wrote in message
...
This is my macro to insert lines if the value in b chanbes. I want it to
inset 26 lines it only inserts 1 please help

Sub Deilv()
Dim LastRow As Long
Dim row_index As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").EntireRow.insert _
(x24ShiftDown)
End If
Next
End Sub




  #3   Report Post  
Esrei
 
Posts: n/a
Default

Thanks it works like a charm.
Now one step more
I want to copy range B2:K25 and insert it ont the 2nd row of the 26 that was
just inserted by the first part of the macro.
Thanks
"Norman Jones" wrote:

Hi Esrei,

Try:

Sub Deilv()
Dim LastRow As Long
Dim row_index As Long

Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").Resize(26).EntireRow. _
Insert Shift:=xlDown
End If
Next
Application.ScreenUpdating = True
End Sub


---
Regards,
Norman



"Esrei" wrote in message
...
This is my macro to insert lines if the value in b chanbes. I want it to
inset 26 lines it only inserts 1 please help

Sub Deilv()
Dim LastRow As Long
Dim row_index As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").EntireRow.insert _
(x24ShiftDown)
End If
Next
End Sub





  #4   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Esrei,

Try:

'===================
Public Sub Deilv2()
Dim LastRow As Long
Dim row_index As Long
Dim rng As Range

Set rng = Range("B2:K25")

Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").Resize(26).EntireRow. _
Insert Shift:=xlDown
rng.Copy Destination:=Cells(row_index + 1, "B").Offset(1)
End If
Next
Application.ScreenUpdating = True
End Sub
'<<===================


---
Regards,
Norman



"Esrei" wrote in message
...
Thanks it works like a charm.
Now one step more
I want to copy range B2:K25 and insert it ont the 2nd row of the 26 that
was
just inserted by the first part of the macro.
Thanks
"Norman Jones" wrote:

Hi Esrei,

Try:

Sub Deilv()
Dim LastRow As Long
Dim row_index As Long

Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").Resize(26).EntireRow. _
Insert Shift:=xlDown
End If
Next
Application.ScreenUpdating = True
End Sub


---
Regards,
Norman



"Esrei" wrote in message
...
This is my macro to insert lines if the value in b chanbes. I want it
to
inset 26 lines it only inserts 1 please help

Sub Deilv()
Dim LastRow As Long
Dim row_index As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").EntireRow.insert _
(x24ShiftDown)
End If
Next
End Sub







  #5   Report Post  
Esrei
 
Posts: n/a
Default

Hi Norman

Thanks a lot

Now these invoices just need totals
In the first row after a value in B in E the word totals must be inserted,
H, I and K must be summed the amount of lines differ on each invoice but
there is a heading from where it must be summed. CTNS(H), QTY(I), Total(K)

Thanks a lot.

"Norman Jones" wrote:

Hi Esrei,

Try:

'===================
Public Sub Deilv2()
Dim LastRow As Long
Dim row_index As Long
Dim rng As Range

Set rng = Range("B2:K25")

Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").Resize(26).EntireRow. _
Insert Shift:=xlDown
rng.Copy Destination:=Cells(row_index + 1, "B").Offset(1)
End If
Next
Application.ScreenUpdating = True
End Sub
'<<===================


---
Regards,
Norman



"Esrei" wrote in message
...
Thanks it works like a charm.
Now one step more
I want to copy range B2:K25 and insert it ont the 2nd row of the 26 that
was
just inserted by the first part of the macro.
Thanks
"Norman Jones" wrote:

Hi Esrei,

Try:

Sub Deilv()
Dim LastRow As Long
Dim row_index As Long

Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").Resize(26).EntireRow. _
Insert Shift:=xlDown
End If
Next
Application.ScreenUpdating = True
End Sub


---
Regards,
Norman



"Esrei" wrote in message
...
This is my macro to insert lines if the value in b chanbes. I want it
to
inset 26 lines it only inserts 1 please help

Sub Deilv()
Dim LastRow As Long
Dim row_index As Long
Application.ScreenUpdating = False
LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
For row_index = LastRow - 1 To 26 Step -1
If Cells(row_index, "B").Value < _
Cells(row_index + 1, "B").Value Then
Cells(row_index + 1, "B").EntireRow.insert _
(x24ShiftDown)
End If
Next
End Sub








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Line Insert Frantic Excel-er Excel Discussion (Misc queries) 4 March 20th 06 11:08 PM
Help: I need a macro to add words every 3 lines Mirandolle Excel Discussion (Misc queries) 11 August 7th 05 05:03 PM
Insert Line Macro Spyder Excel Discussion (Misc queries) 1 March 3rd 05 12:17 AM
How do I insert the date using a macro tara0801 Excel Discussion (Misc queries) 4 February 10th 05 09:09 PM
Challenging Charting C TO Charts and Charting in Excel 0 January 17th 05 06:57 PM


All times are GMT +1. The time now is 04:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"