Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
shanespop2b
 
Posts: n/a
Default To set up a command that will insert a row, every fifth row?

Using Excel, how would you set a a command to auto enter a row, every fifth
row of your data sheet?
  #2   Report Post  
Paul B
 
Posts: n/a
Default

shanespop2b, here is some code that will do it, original code by Dave
Peterson, modified to your needs

Sub Add_Row()
'will add a row after every 5th row
'By: Dave Peterson
Dim iCtr As Long
Dim LastRow As Long
Dim myRng As Range
With ActiveSheet
LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
Set myRng = Nothing
For iCtr = 5 To LastRow Step 5
If myRng Is Nothing Then
Set myRng = .Cells(iCtr, "A")
Else
Set myRng = Union(.Cells(iCtr, "A"), myRng)
End If
Next iCtr
End With

If myRng Is Nothing Then
'do nothing
Else
myRng.EntireRow.Insert
End If
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"shanespop2b" wrote in message
...
Using Excel, how would you set a a command to auto enter a row, every

fifth
row of your data sheet?



  #3   Report Post  
Paul B
 
Posts: n/a
Default

To put in this macro, from your workbook right-click the workbook's icon and
pick View Code. This icon is to the left of the "File" menu this will open
the VBA editor, in the left hand window click on your workbook name, go to
insert, module, and paste the code in the window that opens on the right
hand side, press Alt and Q to close this window and go back to your workbook
and press alt and F8, this will bring up a box to pick the Macro from, click
on the Macro name to run it. If you are using excel 2000 or newer you may
have to change the macro security settings to get the macro to run. To
change the security settings go to tools, macro, security, security level
and set it to medium

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Paul B" wrote in message
...
shanespop2b, here is some code that will do it, original code by Dave
Peterson, modified to your needs

Sub Add_Row()
'will add a row after every 5th row
'By: Dave Peterson
Dim iCtr As Long
Dim LastRow As Long
Dim myRng As Range
With ActiveSheet
LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
Set myRng = Nothing
For iCtr = 5 To LastRow Step 5
If myRng Is Nothing Then
Set myRng = .Cells(iCtr, "A")
Else
Set myRng = Union(.Cells(iCtr, "A"), myRng)
End If
Next iCtr
End With

If myRng Is Nothing Then
'do nothing
Else
myRng.EntireRow.Insert
End If
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"shanespop2b" wrote in message
...
Using Excel, how would you set a a command to auto enter a row, every

fifth
row of your data sheet?





  #4   Report Post  
gls858
 
Posts: n/a
Default

shanespop2b wrote:
Using Excel, how would you set a a command to auto enter a row, every fifth
row of your data sheet?

You might want to take a look at ASAP Utilities. It's a free program
that has MANY useful built in functions. For example for the above you
can do columns or rows by just picking the color and then a number for
every nth row or column. Makes it really easy. Here's the link.
No ads or pop ups.

http://www.asap-utilities.com/

Standard disclaimer: no association of any sort with ASAP Utilities.
I just find it very useful.

gls858
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
Simultaneouly insert of rows or col. - Ajit Ajit Munj Excel Discussion (Misc queries) 1 March 23rd 05 09:17 AM
insert picture BillGwyer Excel Discussion (Misc queries) 1 March 4th 05 06:37 PM
Insert Line Macro Spyder Excel Discussion (Misc queries) 1 March 3rd 05 12:17 AM
Challenging Charting C TO Charts and Charting in Excel 0 January 17th 05 06:57 PM
Function to automatically insert a new sheet as a result of data entry? Mark Mulik Excel Worksheet Functions 2 November 28th 04 02:21 AM


All times are GMT +1. The time now is 05:35 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"