Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Location
    St Petersburg, FL
    Posts
    5

    Unanswered: How do you programmatically add a control to delete said row OnClick?

    I have an Excel spreadsheet that is created from an Ado recordset in Access. The spreadsheet contains 1 row per mailing address. The idea is to have customer service folks scan this list of their clients for people they DO NOT want to send to, and eliminate them (delete the row) by clicking on some sort of control.

    In other words, I need a delete control of some sort on every row with data that deletes itself and its row.

    Any ideas would be appreciated! Thanks in advance!

    Brian Klakring

  2. #2
    Join Date
    Oct 2003
    Posts
    1,091
    Howdy!

    Sounds like a UserForm might be the way to go. Here is an example/discussion about how to do that:

    UserForm example to add/delete
    old, slow, and confused
    but at least I'm inconsistent!

    Rich
    (retired Excel 2003 user, 3/28/2008)

    How to ask a question on forums

  3. #3
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    When ive done this kind of thing before it becomes notroiously difficult to control,
    my advice would be to have a column that the user can double click in to delete the said row using the
    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        
    End Sub
    event

    Dave

  4. #4
    Join Date
    Aug 2004
    Location
    St Petersburg, FL
    Posts
    5

    Thanks for the good advice!

    Thanks for your help! I've gotten past that issue satisfactorily.

    I ended up adding a field to the ADO recordset that populates the worksheet with a column of "DELETE". Then I added the following code to the worksheet...

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    'Delete row if user double-clicks on "Delete"

    If Target.Value = "Delete" Then
    Target.EntireRow.Delete
    End If

    End Sub

    Simple and effective.

    Again, thank you both for your help!

    Brian

Posting Permissions

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