Add delete button in table column ONLY if condition is met.

duteberta

Board Regular
Joined
Jun 14, 2009
Messages
92
Office Version
  1. 365
Platform
  1. MacOS
How do I have a DELETE button appear in the "d" column (Column "data[d]") only if there is a "1" value in the first column? I already have the Delete row macro written and it works fine - I'm just trying to get a better UI.

Here is my test file:
iCloud Drive - Apple iCloud

Screenshot 2024-04-13 at 8.42.54 AM.png
 
My platform is Windows so I cannot test that using a shape (e rectangle, for example) or an icon the result will be Ok for you.
Anyway, those items are "Shapes", so the code of the added block need to be modified as follow:
VBA Code:
    'Added block -->
    Set rngCol1 = Intersect(Target.Cells(1, 1), lo.Range.Columns(1))
    If Not rngCol1 Is Nothing Then
        If rngCol1.Cells(1, 1).Value = 1 Then
            Me.Shapes("myIcon").Visible = msoTrue
            Me.Shapes("myIcon").Top = rngCol1.Cells(1, 1).Top          'TOP
            Me.Shapes("myIcon").Left = rngCol1.Cells(1, 2).Left        'LEFT
        Else
            Me.Shapes("myIcon").Visible = msoFalse
        End If
    End If
    '<-- End Added Block
This assumes that the shape or the icon you inser be renamed myIcon: select the object, type myIcon in the Name box (see image) and confirm using Enter
 

Attachments

  • myIcon.png
    myIcon.png
    33.1 KB · Views: 6
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top