ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting new rows into sheet (https://www.excelbanter.com/excel-programming/439893-inserting-new-rows-into-sheet.html)

Robert Crandal

Inserting new rows into sheet
 
I am using the following code to insert a new row onto
my spreadsheet:

Rows("5:5").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove

This code will insert a new row above the current row number 5, which
is okay. My problem is that the new row has the same height and possibly
dimensions and formatting of row 4.

Can I basically tell Excel to insert a row of cells that are a default size
or
a size of my specification?? I dont want Excel to insert a row of cells
that
are the same dimensions of the above or below row. I realize that I could
write code to resize the new cells, but I am curious if Excel has a setting
to stop it from copying the dimensions of adjacent cells.

Thank you



Jef Gorbach[_2_]

Inserting new rows into sheet
 
Excel normally uses the default formatting when inserting a row,
however you're telling it to copy the format from the row above the
insertion point (via the optional
"CopyOrigin:=xlFormatFromLeftOrAbove" argument).

try simplifying your code to just: Rows("5:5").Insert
Shift:=xlDown

Robert Crandal

Inserting new rows into sheet
 
I must be doing something wrong, because that didn't work. I
tried both of the following options:

Rows("5:5").Insert

and

Rows("5:5").Insert Shift=xlDown


All cells in Row 4 have larger dimensions than all other cells on the
sheet. When I run the above code, Excel creates a row of cells that
all look like Row 4 cells.

Did I do something wrong???




"Jef Gorbach" wrote in message
...

try simplifying your code to just: Rows("5:5").Insert
Shift:=xlDown




All times are GMT +1. The time now is 09:43 AM.

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