Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default insert row method (?)

is there a way to initiate code if a row has been inserted into the
worksheet, and to tell where the row(s) were inserted?

ex: if the user just inserted a new row... do this... (msgbox (you just
inserted row(s)...)

thanks in advance,

-mark



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default insert row method (?)

right click on the sheet tab and select view code

paste in this code:

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox Target.Address
End Sub

Now go back to the sheet and
Insert a row
Delete a row
select a row and hit the delete key to clear the values.

change will tell you that something has happened, but it isn't going to tell
you specifically that it is an insert or a delete - you would to code in more
knowledge of your sheet to discern whether a row insertion or deletion
triggered the change event.

--
Regards,
Tom Ogilvy


"mark kubicki" wrote:

is there a way to initiate code if a row has been inserted into the
worksheet, and to tell where the row(s) were inserted?

ex: if the user just inserted a new row... do this... (msgbox (you just
inserted row(s)...)

thanks in advance,

-mark




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default insert row method (?)

and just to Add, in xl97, if I am remembering correctly, the change event is
triggered on a insertion.

--
Regards,
Tom Ogilvy


"mark kubicki" wrote:

is there a way to initiate code if a row has been inserted into the
worksheet, and to tell where the row(s) were inserted?

ex: if the user just inserted a new row... do this... (msgbox (you just
inserted row(s)...)

thanks in advance,

-mark




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default insert row method (?)

this is good (thanks)

i'm familiar enough withthe change event... any suggestins about what the
could be coded in to discern the insert/delete and the row(s) it occurred
in?

would it make sense to create an array of cell values and addresses, and
then comapre it to the same array generated prior to the change; note the
differences and ...

-mark


"Tom Ogilvy" wrote in message
...
right click on the sheet tab and select view code

paste in this code:

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox Target.Address
End Sub

Now go back to the sheet and
Insert a row
Delete a row
select a row and hit the delete key to clear the values.

change will tell you that something has happened, but it isn't going to
tell
you specifically that it is an insert or a delete - you would to code in
more
knowledge of your sheet to discern whether a row insertion or deletion
triggered the change event.

--
Regards,
Tom Ogilvy


"mark kubicki" wrote:

is there a way to initiate code if a row has been inserted into the
worksheet, and to tell where the row(s) were inserted?

ex: if the user just inserted a new row... do this... (msgbox (you just
inserted row(s)...)

thanks in advance,

-mark






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default insert row method (?)

There is no Universal Truth here. Whatever makes sense to you makes sense.
You know what your worksheets look like and what your users may or may not
do.

but yes, the basic approach is probably one of before and after comparisons.

Maybe add in a little bit of size to the sheet and put a distinct value
below and to the right of actual used range, then check its row and column
location each time against what it used to be. Set the scrollarea and use
the selectionchange event to further prevent selection in this area.

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy


"mark kubicki" wrote:

this is good (thanks)

i'm familiar enough withthe change event... any suggestins about what the
could be coded in to discern the insert/delete and the row(s) it occurred
in?

would it make sense to create an array of cell values and addresses, and
then comapre it to the same array generated prior to the change; note the
differences and ...

-mark


"Tom Ogilvy" wrote in message
...
right click on the sheet tab and select view code

paste in this code:

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox Target.Address
End Sub

Now go back to the sheet and
Insert a row
Delete a row
select a row and hit the delete key to clear the values.

change will tell you that something has happened, but it isn't going to
tell
you specifically that it is an insert or a delete - you would to code in
more
knowledge of your sheet to discern whether a row insertion or deletion
triggered the change event.

--
Regards,
Tom Ogilvy


"mark kubicki" wrote:

is there a way to initiate code if a row has been inserted into the
worksheet, and to tell where the row(s) were inserted?

ex: if the user just inserted a new row... do this... (msgbox (you just
inserted row(s)...)

thanks in advance,

-mark







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
What is the quickest method to insert & name multiple worksheets . clyonesse Excel Worksheet Functions 8 September 20th 05 10:55 PM
What is the quickest method to insert & name multiple worksheets . clyonesse Excel Worksheet Functions 0 January 20th 05 06:15 PM
Any method available to insert pic into comment box?? C Excel Discussion (Misc queries) 1 January 15th 05 12:30 AM
Insert method of range class failed quartz[_2_] Excel Programming 0 August 17th 04 07:31 PM
Insert method of range class failed DJH Excel Programming 0 August 17th 04 07:30 PM


All times are GMT +1. The time now is 07:26 AM.

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"