ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting a BLANK row (https://www.excelbanter.com/excel-programming/385235-inserting-blank-row.html)

tom

Inserting a BLANK row
 
Hi all,
I have a sheet that has a range that starts from row 33 and MAY (depending
on how many parameters/rows of data are required) extend up to row 43. What I
would like to do is insert a BLANK row between the lines of data. (Data is
column C).
I think the best way would be to search from row 33 down to see where the
last row of data is, then insert blank rows between the lines that contain
data.
Any help would be greatly appreciated!

merjet

Inserting a BLANK row
 
You need to tell us how the last row of a set is identified.

Merjet



Mike

Inserting a BLANK row
 
Try this. Finds the last used row in Col C and inserts a blank line between
rows up to row 33.

Sub insertrows()
lastrowcolc = Range("C65536").End(xlUp).Row
For x = lastrowcolc To 2 Step -1
Rows(x).Select
Selection.Insert Shift:=xlDown
Next
End Sub

Mike


"Tom" wrote:

Hi all,
I have a sheet that has a range that starts from row 33 and MAY (depending
on how many parameters/rows of data are required) extend up to row 43. What I
would like to do is insert a BLANK row between the lines of data. (Data is
column C).
I think the best way would be to search from row 33 down to see where the
last row of data is, then insert blank rows between the lines that contain
data.
Any help would be greatly appreciated!


Mike

Inserting a BLANK row
 
Sorry should be

For x = lastrowcolc To 34 Step -1


"Mike" wrote:

Try this. Finds the last used row in Col C and inserts a blank line between
rows up to row 33.

Sub insertrows()
lastrowcolc = Range("C65536").End(xlUp).Row
For x = lastrowcolc To 2 Step -1
Rows(x).Select
Selection.Insert Shift:=xlDown
Next
End Sub

Mike


"Tom" wrote:

Hi all,
I have a sheet that has a range that starts from row 33 and MAY (depending
on how many parameters/rows of data are required) extend up to row 43. What I
would like to do is insert a BLANK row between the lines of data. (Data is
column C).
I think the best way would be to search from row 33 down to see where the
last row of data is, then insert blank rows between the lines that contain
data.
Any help would be greatly appreciated!


tom

Inserting a BLANK row
 
Hi Mike,
Thanks for taking the time to respond with a solution. This code does
work...however, can it be changed so that it does not copy the cell formats
from above/below....ie, cell border formatting. i would like the cells
completely empty with no borders on them. The cells above/below them DO have
borders and I'm assuming that this is copying the cell format from them.

thanks!

"Mike" wrote:

Sorry should be

For x = lastrowcolc To 34 Step -1


"Mike" wrote:

Try this. Finds the last used row in Col C and inserts a blank line between
rows up to row 33.

Sub insertrows()
lastrowcolc = Range("C65536").End(xlUp).Row
For x = lastrowcolc To 2 Step -1
Rows(x).Select
Selection.Insert Shift:=xlDown
Next
End Sub

Mike


"Tom" wrote:

Hi all,
I have a sheet that has a range that starts from row 33 and MAY (depending
on how many parameters/rows of data are required) extend up to row 43. What I
would like to do is insert a BLANK row between the lines of data. (Data is
column C).
I think the best way would be to search from row 33 down to see where the
last row of data is, then insert blank rows between the lines that contain
data.
Any help would be greatly appreciated!


Mike

Inserting a BLANK row
 
Tom,

It's not copying anything, if the original cells have borders then these
will be stretched when the new rows are inserted. This will remove them but
it's a bit of a mess because I don't know what borders I'm dealing with.

Sub insertrows()
lastrowcolc = Range("C65536").End(xlUp).Row
For x = lastrowcolc To 2 Step -1
Rows(x).Select
Selection.Insert Shift:=xlDown
Cells(x, 3).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Next
End Sub

"Tom" wrote:

Hi Mike,
Thanks for taking the time to respond with a solution. This code does
work...however, can it be changed so that it does not copy the cell formats
from above/below....ie, cell border formatting. i would like the cells
completely empty with no borders on them. The cells above/below them DO have
borders and I'm assuming that this is copying the cell format from them.

thanks!

"Mike" wrote:

Sorry should be

For x = lastrowcolc To 34 Step -1


"Mike" wrote:

Try this. Finds the last used row in Col C and inserts a blank line between
rows up to row 33.

Sub insertrows()
lastrowcolc = Range("C65536").End(xlUp).Row
For x = lastrowcolc To 2 Step -1
Rows(x).Select
Selection.Insert Shift:=xlDown
Next
End Sub

Mike


"Tom" wrote:

Hi all,
I have a sheet that has a range that starts from row 33 and MAY (depending
on how many parameters/rows of data are required) extend up to row 43. What I
would like to do is insert a BLANK row between the lines of data. (Data is
column C).
I think the best way would be to search from row 33 down to see where the
last row of data is, then insert blank rows between the lines that contain
data.
Any help would be greatly appreciated!



All times are GMT +1. The time now is 10:22 PM.

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