Adding command button to multiple rows in Excel worksheet based on cell value

GalaxyFlip4

New Member
Joined
Oct 16, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have a worksheet(names, home address, action, email address, submission date) where rows of data will be added over time.

I desire a command button to the added to the end of the data row if a specific cell(Action column) in the row states "Pick up".

If the specific cell in states otherwise, no command button is added to the end of the row.

Could a looping macro achieve this?

I will use the command buttons to send email to clients only in that row.

Please see attached screenshot for clarification.

Thank you all very much.

Best,

Dion
<>
 

Attachments

  • ScreenShot.PNG
    ScreenShot.PNG
    59.3 KB · Views: 14

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Personally, I wouldn't go down the command button path, but rather use a before double click event code instead. The end result would be the same, but the code would be a lot simpler. Try the following on the sheet code area of the sheet of your image. On double click on column H, you will trigger your email code (which I assume you already have) if the cell contains the word "Mail".

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, cancel As Boolean)
    If Target.Column <> 8 Then Exit Sub
        Application.EnableEvents = False
        If Target.Value = "Mail" Then
        
            '**** your email code goes here ****
        
        End If
        cancel = True
        Application.EnableEvents = True
End Sub
 
Upvote 0
Personally, I wouldn't go down the command button path, but rather use a before double click event code instead. The end result would be the same, but the code would be a lot simpler. Try the following on the sheet code area of the sheet of your image. On double click on column H, you will trigger your email code (which I assume you already have) if the cell contains the word "Mail".

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, cancel As Boolean)
    If Target.Column <> 8 Then Exit Sub
        Application.EnableEvents = False
        If Target.Value = "Mail" Then
       
            '**** your email code goes here ****
       
        End If
        cancel = True
        Application.EnableEvents = True
End Sub
Thank you Kevin9999, I will give it a shot.

Best,
 
Upvote 0

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

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