+ Reply to Thread
Results 1 to 8 of 8

Identify button (shape) row to insert row and delete row

  1. #1
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    Identify button (shape) row to insert row and delete row

    I have a button (group containing and add and delete button).
    I want to identify the row (position of shape/button calling the macro) to enable inserting a new row (1 row down from current row).

    Then do the same to delete a row (position of shape/button calling the macro) to enable deletion of selected row.

    This will allow me to add/insert rows by the button located at that row

    The problem i have is getting the row property (row position of the button eg. TopLeftCell.Row) of the add button. The add button (RowBtnAdd) is a shape within a group (BtnGrp)

    I also note that when a group is copied, it has the same shape name as that copied.
    I want to keep the add and delete shape within the group (BtnGrp).
    I do not want to select a cell or row or enter a row number to delete etc.

    refer to sample workbook attached. Currently only has one record row.

    code so far -
    Please Login or Register  to view this content.

    Any help would be much appreciated.
    Attached Files Attached Files
    Last edited by wotadude; 02-08-2009 at 03:18 PM.

  2. #2
    Registered User
    Join Date
    04-26-2007
    Posts
    10

    Re: Identify button (shape) row to insert row and delete row

    Maybe this isnt the answer you wanted, but I also had a situation/project that called for this.
    However I changed my approach, instead of having a button for every row, I created custom menu on right click (to delete row or add row).

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,480

    Re: Identify button (shape) row to insert row and delete row

    The application.caller returns the name of the Add button but that does not exist in the Shapes collection. The grouped item is what is in the collection.

    You can use the groupitems collection to determine whether the caller is in that group. Obviously your problem comes when all the controls have the same name. There is no way of determining which group the button belongs to.

    You would need to give each control within the group a uniqe name.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    Re: Identify button (shape) row to insert row and delete row

    Thanks so far people.

    i will rename each grouped item after copy somehow to make them unqiue.

    can i have example of how to get the grouped item name & row?.

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Identify button (shape) row to insert row and delete row

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,480

    Re: Identify button (shape) row to insert row and delete row

    Looks like a muddle up a couple of threads.

    try this code.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    08-21-2008
    Location
    Hamilton, New Zealand
    MS-Off Ver
    Office 2007
    Posts
    255

    Re: Identify button (shape) row to insert row and delete row

    Andy that is just what the job requires.
    Your help is much appreciated.
    When i get 5, i will have to get my head around what make this think work.

  8. #8
    Registered User
    Join Date
    03-20-2012
    Location
    France
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Identify button (shape) row to insert row and delete row

    Hello,

    This code is perfect for what I want to do !! That's exactly what I need !

    But when I try to use it in another file, with several columns wich include formulas, I have an error 1004. VBA tells me that this comes from this line :
    Sub UpdateNames(MyGroup As Shape)
    (…)
    For Each shpTemp In MyGroup.GroupItems
    Edit : the file I uploaded show the error when you click on add buttons and add text or formulas in columns.
    I tried on Excel 2007 and 2010.

    Do you have any idea please ?
    I really need this code to work for my personal project !

    Thanks a lot for every suggestion .

    (yes, this is an old post but that's the only code on the interne that seems to add/remove rows with buttons. If you know anything else like this, I will look at it )
    Attached Files Attached Files
    Last edited by kodomo; 03-22-2012 at 01:17 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1