Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Insert rows without copying borders and shading

I am coding a sheet in which I need to insert multiple rows and I have a
function that I can call that does this splendidly. The problem arises if you
have a row with shading and borders ABOVE the row on which you are doing an
insert, then the borders and shading from the row above is copied down when
the insert is done.

I just want to do a row insert without the cell shading and borders being
copied down using VBA code. Can someone give me an easier way than having to
reformat everything every time?

My current function I'm using is below (remove row wrapping):

Public Function RowsInsert(argStartCell As String, argRowsToInsert As Long)
Range(Range(argStartCell).Address,
Range(Range(argStartCell).Offset(argRowsToInsert,
0).Address)).EntireRow.Insert Shift:=xlDown
End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Insert rows without copying borders and shading

I believe a function must return a value, so what you have written should
probably be a Sub since it is designed to perform an action. You would have
to use the PasteSpecial method to exclude the format properties when copying
data from one range to another. e.g. MySheet.myRange.PasteSpecial
Paste:=xlPasteValues

"XP" wrote:

I am coding a sheet in which I need to insert multiple rows and I have a
function that I can call that does this splendidly. The problem arises if you
have a row with shading and borders ABOVE the row on which you are doing an
insert, then the borders and shading from the row above is copied down when
the insert is done.

I just want to do a row insert without the cell shading and borders being
copied down using VBA code. Can someone give me an easier way than having to
reformat everything every time?

My current function I'm using is below (remove row wrapping):

Public Function RowsInsert(argStartCell As String, argRowsToInsert As Long)
Range(Range(argStartCell).Address,
Range(Range(argStartCell).Offset(argRowsToInsert,
0).Address)).EntireRow.Insert Shift:=xlDown
End Function

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Insert rows without copying borders and shading


Pete, Did you TRY IT FIRST???
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Pete Rooney" wrote in message
...
Doesn't this only incert a cell down as against a whole row, which would
be:

Sub InsertRowNoFormat()
With ActiveCell
.EntireRow.Insert
.EntireRow.ClearFormats
End With
End Sub

Cheers

Pete

"Don Guillett" wrote:

Sub insertrownoformat()
With ActiveCell
.Rows.Insert
.ClearFormats
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"XP" wrote in message
...
I am coding a sheet in which I need to insert multiple rows and I have a
function that I can call that does this splendidly. The problem arises
if
you
have a row with shading and borders ABOVE the row on which you are
doing
an
insert, then the borders and shading from the row above is copied down
when
the insert is done.

I just want to do a row insert without the cell shading and borders
being
copied down using VBA code. Can someone give me an easier way than
having
to
reformat everything every time?

My current function I'm using is below (remove row wrapping):

Public Function RowsInsert(argStartCell As String, argRowsToInsert As
Long)
Range(Range(argStartCell).Address,
Range(Range(argStartCell).Offset(argRowsToInsert,
0).Address)).EntireRow.Insert Shift:=xlDown
End Function






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Insert rows without copying borders and shading

I apologize. Went back and did this.

Sub insertrownoformat()
With ActiveCell
.EntireRow.Insert
.Offset(-1).EntireRow.ClearFormats
End With
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...

Pete, Did you TRY IT FIRST???
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Pete Rooney" wrote in message
...
Doesn't this only incert a cell down as against a whole row, which would
be:

Sub InsertRowNoFormat()
With ActiveCell
.EntireRow.Insert
.EntireRow.ClearFormats
End With
End Sub

Cheers

Pete

"Don Guillett" wrote:

Sub insertrownoformat()
With ActiveCell
.Rows.Insert
.ClearFormats
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"XP" wrote in message
...
I am coding a sheet in which I need to insert multiple rows and I have
a
function that I can call that does this splendidly. The problem arises
if
you
have a row with shading and borders ABOVE the row on which you are
doing
an
insert, then the borders and shading from the row above is copied down
when
the insert is done.

I just want to do a row insert without the cell shading and borders
being
copied down using VBA code. Can someone give me an easier way than
having
to
reformat everything every time?

My current function I'm using is below (remove row wrapping):

Public Function RowsInsert(argStartCell As String, argRowsToInsert As
Long)
Range(Range(argStartCell).Address,
Range(Range(argStartCell).Offset(argRowsToInsert,
0).Address)).EntireRow.Insert Shift:=xlDown
End Function





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Insert rows without copying borders and shading

Good morning, Don,

Terrified though I am of correcting ANYONE on here, yes, I did try it -
which is how I found it didn't work, because it just inserted one cell down!
:-)

Regards

Pete


"Don Guillett" wrote:

I apologize. Went back and did this.

Sub insertrownoformat()
With ActiveCell
.EntireRow.Insert
.Offset(-1).EntireRow.ClearFormats
End With
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...

Pete, Did you TRY IT FIRST???
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Pete Rooney" wrote in message
...
Doesn't this only incert a cell down as against a whole row, which would
be:

Sub InsertRowNoFormat()
With ActiveCell
.EntireRow.Insert
.EntireRow.ClearFormats
End With
End Sub

Cheers

Pete

"Don Guillett" wrote:

Sub insertrownoformat()
With ActiveCell
.Rows.Insert
.ClearFormats
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"XP" wrote in message
...
I am coding a sheet in which I need to insert multiple rows and I have
a
function that I can call that does this splendidly. The problem arises
if
you
have a row with shading and borders ABOVE the row on which you are
doing
an
insert, then the borders and shading from the row above is copied down
when
the insert is done.

I just want to do a row insert without the cell shading and borders
being
copied down using VBA code. Can someone give me an easier way than
having
to
reformat everything every time?

My current function I'm using is below (remove row wrapping):

Public Function RowsInsert(argStartCell As String, argRowsToInsert As
Long)
Range(Range(argStartCell).Address,
Range(Range(argStartCell).Offset(argRowsToInsert,
0).Address)).EntireRow.Insert Shift:=xlDown
End Function






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
freeze borders and shading willem Excel Discussion (Misc queries) 2 January 9th 09 12:40 PM
Copying cell border formatting, without shading. Jamie Excel Programming 3 January 14th 08 05:41 PM
insert row keeping borders Lise Excel Discussion (Misc queries) 1 May 6th 06 05:36 PM
Copyin text only...not borders or shading LS Excel Worksheet Functions 1 April 21st 06 09:40 PM
Same formula in each cell of column; insert rows w/o copying down tgdavis Excel Discussion (Misc queries) 3 September 14th 05 09:32 PM


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