PC Review


Reply
Thread Tools Rate Thread

Can I set Insert Options programmatically?

 
 
Brian Knittel
Guest
Posts: n/a
 
      6th Aug 2008
Is there a way to set the row Insert Options programmatically in Excel 2003?
I haven't been able to find any object that encompasses this.

What I want is to to be able to have a macro insert a row using the "Format
Same As Above" option, but I don't want the user to have to set this
manually or have to live with the option set if they don't want to. What I
want to do is save the original setting, change it to Format Same As Above,
insert the row, then restore the original setting.

Of course I can copy the various properties from the cells in the row above,
but it's not as nice as having the row just pop into place ready to go.

Any advice would be greatly appreciated.

Brian



 
Reply With Quote
 
 
 
 
Office_Novice
Guest
Posts: n/a
 
      6th Aug 2008
Try somthing like
'Everytime the cell changes this will insert a new formated row
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Rows(1).Insert Shift:=xlDown, CopyOrigin:=xlFormats
End Sub


"Brian Knittel" wrote:

> Is there a way to set the row Insert Options programmatically in Excel 2003?
> I haven't been able to find any object that encompasses this.
>
> What I want is to to be able to have a macro insert a row using the "Format
> Same As Above" option, but I don't want the user to have to set this
> manually or have to live with the option set if they don't want to. What I
> want to do is save the original setting, change it to Format Same As Above,
> insert the row, then restore the original setting.
>
> Of course I can copy the various properties from the cells in the row above,
> but it's not as nice as having the row just pop into place ready to go.
>
> Any advice would be greatly appreciated.
>
> Brian
>
>
>
>

 
Reply With Quote
 
Brian Knittel
Guest
Posts: n/a
 
      7th Aug 2008
Interesting, on my copy of Excel and on the msdn online documentation, the
help page doesn't really describe the CopyOrigin argument, and entirely
omits mention of the Shift argument.
(http://msdn.microsoft.com/en-us/library/aa195769(office.11).aspx)

That aside, Rows(1).Insert Shift:=xlDown, CopyOrigin:=xlFormats doesn't do
the same thing as a row insert with "Format Same As Above" selected. This
code inserts a row above the specified row, using that row's formatting. In
other words, the flow of formatting is still "upwards."

What I want is to insert a row *below* the specified row, using that row's
formatting. In other words I start with this

+---------+
| AAA |
+---------+
| BBB |
+---------+

and want end up with this:

+---------+
| AAA |
+---------+
| aaa | <-- this is the new row
+---------+
| BBB |
+---------+

I want the names defined in row AAA its formulas and values to stay exactly
as they are.
I just want row aaa to have the same formatting as AAA (borders,
interior,protection, cell format, etc).

Using Rows(1).Insert Shift:=xlDown, CopyOrigin:=xlFormats I get this

+---------+
| aaa | <-- this is the new row
+---------+
| AAA |
+---------+
| BBB |
+---------+

Any other ideas on how to programmatically control the Format Same As Above
setting?

Brian

"Office_Novice" <(E-Mail Removed)> wrote...
> Try somthing like
> Rows(1).Insert Shift:=xlDown, CopyOrigin:=xlFormats



 
Reply With Quote
 
Brian Knittel
Guest
Posts: n/a
 
      7th Aug 2008
ummm, forget I said this:
> ...and entirely omits mention of the Shift argument.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programmatically Set Startup Options nomadk Microsoft Access 3 9th Oct 2008 05:40 PM
Set Access Options Programmatically =?Utf-8?B?cnR2aXBlcg==?= Microsoft Access Form Coding 1 5th Oct 2007 07:22 PM
Set Options Programmatically =?Utf-8?B?R2VuaWU3NQ==?= Spyware Discussion 1 20th May 2006 12:29 AM
unchecking options in a task programmatically tmoakes@gmail.com Microsoft Outlook VBA Programming 0 20th Jul 2005 12:08 PM
Programmatically Changing Printer Options slk23 Microsoft C# .NET 1 3rd Nov 2004 06:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:59 AM.