ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   urgent help (https://www.excelbanter.com/excel-discussion-misc-queries/95459-urgent-help.html)

b166er

urgent help
 

hi members
how can I insert rows after every fiftth row I have data of more than
6000 rows that means I want to insert 2000 rows in that sequence


--
b166er
------------------------------------------------------------------------
b166er's Profile: http://www.excelforum.com/member.php...o&userid=34912
View this thread: http://www.excelforum.com/showthread...hreadid=554563


Bob Phillips

urgent help
 
Don't multi-post.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"b166er" wrote in
message ...

hi members
how can I insert rows after every fiftth row I have data of more than
6000 rows that means I want to insert 2000 rows in that sequence


--
b166er
------------------------------------------------------------------------
b166er's Profile:

http://www.excelforum.com/member.php...o&userid=34912
View this thread: http://www.excelforum.com/showthread...hreadid=554563




Kevin B

urgent help
 
I've tested the code and it worked okay, but make a back up copy of your
workbook just in case. The macro assumes that the data is on Sheet1 of the
workbook and starts in column A1.

Press Alt+F11 to open VBE. Click on INSERT in the VBE menu and select
MODULE. Copy and paste the code below into the module. close the VBE and in
Excel click TOOLS, select MACROS, select MACRO, highlight the macro
InsertMoreRows and click the run button.

Sub InsertMoreRows()

Dim wb As Workbook
Dim ws As Worksheet
Dim lngRowCounter As Long
Dim lngOffset As Long
Set wb = ActiveWorkbook
Set ws = wb.Worksheets("Sheet1")

ws.Activate
Range("A1").Select

Do Until lngRowCounter = 2000
lngOffset = lngOffset + 5
ActiveCell.Offset(lngOffset).EntireRow.Insert
lngRowCounter = lngRowCounter + 1
Loop

Set ws = Nothing
Set wb = Nothing

End Sub

--
Kevin Backmann


"b166er" wrote:


hi members
how can I insert rows after every fiftth row I have data of more than
6000 rows that means I want to insert 2000 rows in that sequence


--
b166er
------------------------------------------------------------------------
b166er's Profile: http://www.excelforum.com/member.php...o&userid=34912
View this thread: http://www.excelforum.com/showthread...hreadid=554563




All times are GMT +1. The time now is 08:37 PM.

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