Hi all,
Below I have some code which adds the contents of 30 cells to a right click menu bar structure. The text in each cell becomes the caption for a control button.
How do I capture the caption of the button later? In other words, if someone clicks on a button that has a caption of “5am – 1pm” then I want that cell to contain “5am – 1pm”
Would prefer to use one onaction sub and somehow tranfer the caption to it instead of writing 30 separate subs for each button.
Sub RC() Dim mybar As CommandBar Dim b As Integer Application.CommandBars("cell").Enabled = False On Error Resume Next Set mybar = CommandBars.Add(Name:="RCShifts", Position:=msoBarPopup, _ Temporary:=False) With CommandBars("RCShifts") For b = 1 To 30 .Controls.Add Type:=msoControlButton With CommandBars("RCShifts").Controls(.Caption = ActiveSheet.Cells(46 + b, 3).Value .OnAction = "EntShifts" End With Next End With Set a = Nothing End Sub Sub EntShifts() 'Cell.Value = Whatever the caption of the button pressed is End Sub