Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Adding blank rows every 3rd row

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Const FIRST_ROW As Long = 0 '<=== set to 2,1, or 0
Dim i As Long
Dim iLastRow As Long
Dim cell As Range
Dim sh As Worksheet

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - (iLastRow Mod 3) To 2 Step -3
Rows(i).Insert
Next i

End With

End Sub


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"liz25mc" wrote in message
...
Can someone provide coding to add a blank row every 3rd row in Excel 2003.

Thanks in advance!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Adding blank rows every 3rd row

To partially plagarize you Bob, she's wanting this to show every 3rd
row starting at the top as a blank, with a header row...

liz25mc,
Change this: For i = iLastRow - (iLastRow Mod 3) To 2 Step -3
To this: For i = 5 To (iLastRow - (iLastRow Mod 3)) Step 3

ALSO, in Bob's code, you don't need these lines, unless you're using
them somewhere else...

Const FIRST_ROW As Long = 0 '<=== set to 2,1, or 0
Dim cell As Range
Dim sh As Worksheet

The Const TEST_COLUMN As String = "A" sets the column your looking at.
So, if your data is in column B, change that to B, etc...

Rob


liz25mc wrote:
Hi Bob,

Thanks for the code. I'm not sure I understand what:
Const TEST_COLUMN as String = "A" does.

The first row iin the spreadsheet contains field names (sorry, I should have
mentioned that in my previous post).
When I run the code I get two rows and then a blank on the first three rows,
and then a blank after every third row in the rest of the spreadsheet.
Wondering what I am doing wrong, and hope you can set me straight on what
changes I need to make to the code.

Thanks again.

"Bob Phillips" wrote:

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Const FIRST_ROW As Long = 0 '<=== set to 2,1, or 0
Dim i As Long
Dim iLastRow As Long
Dim cell As Range
Dim sh As Worksheet

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - (iLastRow Mod 3) To 2 Step -3
Rows(i).Insert
Next i

End With

End Sub


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"liz25mc" wrote in message
...
Can someone provide coding to add a blank row every 3rd row in Excel 2003.

Thanks in advance!





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Adding blank rows every 3rd row

I went bottom up for a very good reason, if you insert rows in a block of
data, you won't process it all, it will terminate before the last row
(because these rows get shifted down).

Also FIRST_ROW is part of the code, I just forgot to include it

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Const FIRST_ROW As Long = 2 '<=== set to 2,1, or 0
Dim i As Long
Dim iLastRow As Long
Dim cell As Range
Dim sh As Worksheet

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - FIRST_ROW To 2 Step -3
Rows(i).Insert
Next i

End With

End Sub

it determines where the blank is inserted, and is to facilitate tuning.


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"okrob" wrote in message
oups.com...
To partially plagarize you Bob, she's wanting this to show every 3rd
row starting at the top as a blank, with a header row...

liz25mc,
Change this: For i = iLastRow - (iLastRow Mod 3) To 2 Step -3
To this: For i = 5 To (iLastRow - (iLastRow Mod 3)) Step 3

ALSO, in Bob's code, you don't need these lines, unless you're using
them somewhere else...

Const FIRST_ROW As Long = 0 '<=== set to 2,1, or 0
Dim cell As Range
Dim sh As Worksheet

The Const TEST_COLUMN As String = "A" sets the column your looking at.
So, if your data is in column B, change that to B, etc...

Rob


liz25mc wrote:
Hi Bob,

Thanks for the code. I'm not sure I understand what:
Const TEST_COLUMN as String = "A" does.

The first row iin the spreadsheet contains field names (sorry, I should
have
mentioned that in my previous post).
When I run the code I get two rows and then a blank on the first three
rows,
and then a blank after every third row in the rest of the spreadsheet.
Wondering what I am doing wrong, and hope you can set me straight on what
changes I need to make to the code.

Thanks again.

"Bob Phillips" wrote:

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Const FIRST_ROW As Long = 0 '<=== set to 2,1, or 0
Dim i As Long
Dim iLastRow As Long
Dim cell As Range
Dim sh As Worksheet

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - (iLastRow Mod 3) To 2 Step -3
Rows(i).Insert
Next i

End With

End Sub


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"liz25mc" wrote in message
...
Can someone provide coding to add a blank row every 3rd row in Excel
2003.

Thanks in advance!







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Adding blank rows every 3rd row

I see what you have there Bob...
When I ran it on about 1500 rows, it stopped inserting at about row
1500.
Shoulda seen that before shootin off my lip.. :0)
Rob



Bob Phillips wrote:
I went bottom up for a very good reason, if you insert rows in a block of
data, you won't process it all, it will terminate before the last row
(because these rows get shifted down).

Also FIRST_ROW is part of the code, I just forgot to include it

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Const FIRST_ROW As Long = 2 '<=== set to 2,1, or 0
Dim i As Long
Dim iLastRow As Long
Dim cell As Range
Dim sh As Worksheet

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - FIRST_ROW To 2 Step -3
Rows(i).Insert
Next i

End With

End Sub

it determines where the blank is inserted, and is to facilitate tuning.


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"okrob" wrote in message
oups.com...
To partially plagarize you Bob, she's wanting this to show every 3rd
row starting at the top as a blank, with a header row...

liz25mc,
Change this: For i = iLastRow - (iLastRow Mod 3) To 2 Step -3
To this: For i = 5 To (iLastRow - (iLastRow Mod 3)) Step 3

ALSO, in Bob's code, you don't need these lines, unless you're using
them somewhere else...

Const FIRST_ROW As Long = 0 '<=== set to 2,1, or 0
Dim cell As Range
Dim sh As Worksheet

The Const TEST_COLUMN As String = "A" sets the column your looking at.
So, if your data is in column B, change that to B, etc...

Rob


liz25mc wrote:
Hi Bob,

Thanks for the code. I'm not sure I understand what:
Const TEST_COLUMN as String = "A" does.

The first row iin the spreadsheet contains field names (sorry, I should
have
mentioned that in my previous post).
When I run the code I get two rows and then a blank on the first three
rows,
and then a blank after every third row in the rest of the spreadsheet.
Wondering what I am doing wrong, and hope you can set me straight on what
changes I need to make to the code.

Thanks again.

"Bob Phillips" wrote:

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Const FIRST_ROW As Long = 0 '<=== set to 2,1, or 0
Dim i As Long
Dim iLastRow As Long
Dim cell As Range
Dim sh As Worksheet

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow - (iLastRow Mod 3) To 2 Step -3
Rows(i).Insert
Next i

End With

End Sub


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"liz25mc" wrote in message
...
Can someone provide coding to add a blank row every 3rd row in Excel
2003.

Thanks in advance!






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
Linked sheets, blank cells and adding new rows CharlieJane Excel Worksheet Functions 1 July 25th 08 07:12 PM
Adding blank rows between groups of similar names Justin Excel Worksheet Functions 2 July 6th 07 07:28 PM
Excel adding blank rows when sorting [email protected] Excel Discussion (Misc queries) 2 September 23rd 06 05:30 PM
Adding additional rows BEFORE first blank row (????) JoeJoe Excel Programming 2 August 31st 06 03:08 AM
adding blank rows greg malenky Excel Programming 2 October 23rd 03 05:35 PM


All times are GMT +1. The time now is 04:12 PM.

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

About Us

"It's about Microsoft Excel"