Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
Jsut wondering whether theres a worksheet function or code that could automatically insert a row for every 20,000 row? or just every X row?? Thanks for your help :D Elaine. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Public Sub ProcessData() Const TEST_COLUMN As String = "A" '<=== change to suit Const INSERT_ROW As Long = 5 '<=== CHANGE TO SUIT Dim i As Long Dim iLastRow As Long With ActiveSheet iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row iLastRow = iLastRow + INSERT_ROW - iLastRow Mod INSERT_ROW For i = iLastRow To 1 Step -INSERT_ROW Rows(i).Insert Next i End With End Sub -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "elaine" wrote in message oups.com... Hi all, Jsut wondering whether theres a worksheet function or code that could automatically insert a row for every 20,000 row? or just every X row?? Thanks for your help :D Elaine. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bob!
It does exactly what i wanted to! Thanks so much! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Elaine,
Adjust as needed: Dim i As Long Const ROWJUMP As Long = 20000 For i = 1 To Rows.Count Step ROWJUMP Rows(i & ":" & i).Insert Shift:=xlDown 'Just to see where rows added Rows(i & ":" & i).Interior.ColorIndex = 10 Next NickHK "elaine" wrote in message oups.com... Hi all, Jsut wondering whether theres a worksheet function or code that could automatically insert a row for every 20,000 row? or just every X row?? Thanks for your help :D Elaine. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you guys, they work perfectly. Just wondering is there a way I
can insert X rows every Y rows? Thanks for your help :) elaine. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Elaine,
Try this: Private Sub CommandButton1_Click() RowInsertion Range("A10"), 100, 10 End Sub Private Sub RowInsertion(argStartCell As Range, RowsToJump As Long, Optional RowsToInset As Long = 1) Dim i As Long For i = argStartCell.Row To Rows.Count Step RowsToJump Rows(i & ":" & i + RowsToInset - 1).Insert Shift:=xlDown 'Just to see where rows added Rows(i & ":" & i + RowsToInset - 1).Interior.ColorIndex = 10 Next End Function NickHK "elaine" wrote in message oups.com... Thank you guys, they work perfectly. Just wondering is there a way I can insert X rows every Y rows? Thanks for your help :) elaine. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi NickHK,
your code is taking a long time to run, i guess it is trying to add rows to the whole spreadsheet (ie ~1 Million rows). Is it possible if it could jsut add rows to the range that has data?? Thanks very much. Elaine. On 30 Apr, 11:29, "NickHK" wrote: Elaine, Try this: Private Sub CommandButton1_Click() RowInsertion Range("A10"), 100, 10 End Sub Private Sub RowInsertion(argStartCell As Range, RowsToJump As Long, Optional RowsToInset As Long = 1) Dim i As Long For i = argStartCell.Row To Rows.Count Step RowsToJump Rows(i & ":" & i + RowsToInset - 1).Insert Shift:=xlDown 'Just to see where rows added Rows(i & ":" & i + RowsToInset - 1).Interior.ColorIndex = 10 Next End Function NickHK "elaine" wrote in message oups.com... Thank you guys, they work perfectly. Just wondering is there a way I can insert X rows every Y rows? Thanks for your help :) elaine.- Hide quoted text - - Show quoted text - |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub RowInsertion(argStartCell As Range, RowsToJump As Long, Optional
RowsToInset As Long = 1) Dim i As Long For i = argStartCell.Row To Cells(Rows.Count, argStartCell.Column).End(xlUp).Row Step RowsToJump Rows(i & ":" & i + RowsToInset - 1).Insert Shift:=xlDown 'Just to see where rows added Rows(i & ":" & i + RowsToInset - 1).Interior.ColorIndex = 10 Next -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "elaine" wrote in message ups.com... Hi NickHK, your code is taking a long time to run, i guess it is trying to add rows to the whole spreadsheet (ie ~1 Million rows). Is it possible if it could jsut add rows to the range that has data?? Thanks very much. Elaine. On 30 Apr, 11:29, "NickHK" wrote: Elaine, Try this: Private Sub CommandButton1_Click() RowInsertion Range("A10"), 100, 10 End Sub Private Sub RowInsertion(argStartCell As Range, RowsToJump As Long, Optional RowsToInset As Long = 1) Dim i As Long For i = argStartCell.Row To Rows.Count Step RowsToJump Rows(i & ":" & i + RowsToInset - 1).Insert Shift:=xlDown 'Just to see where rows added Rows(i & ":" & i + RowsToInset - 1).Interior.ColorIndex = 10 Next End Function NickHK "elaine" wrote in message oups.com... Thank you guys, they work perfectly. Just wondering is there a way I can insert X rows every Y rows? Thanks for your help :) elaine.- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Cannot insert worksheet in exel - not available in insert menu | Excel Worksheet Functions | |||
insert row / insert column command buttons | Excel Worksheet Functions | |||
Macro to insert copy and insert formulas only to next blank row | Excel Programming | |||
Can I auto insert a worksheet when I insert a value in a cell. | Excel Worksheet Functions | |||
Insert cell/format/text/fontsize and auto insert into header? | Excel Programming |