ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   checkBox & ListBox on ToolBar... (https://www.excelbanter.com/excel-programming/408190-checkbox-listbox-toolbar.html)

Johan2000

checkBox & ListBox on ToolBar...
 
Is that possible to have an checkBox and/or ListBox on
the toolbar.... so the code bellow will be run if checkBox is check, and
listBox
pointing to currency...

Thank You

/ How to modify the content of the current Cell in Excel
// put this code in Excel/VisualBasic/MsProject/ExCellObject/Worksheet1
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As String
x = Target.Value
If Right(x, 1) = "*" Then
Target.Value = Replace(x, "*", "000")
End If
End Sub

Patrick Molloy[_2_]

checkBox & ListBox on ToolBar...
 
this needs tweaking, but is enough to get you started:

Option Explicit
Global drpdwn As CommandBarComboBox

Sub SetMenuBar()
Dim newbar As CommandBar
Dim cntrl As CommandBarButton
If BarExists Then
CommandBars("Patrick").Delete
End If
Set newbar = CommandBars.Add("Patrick", msoBarFloating)
Set drpdwn = newbar.Controls.Add(msoControlComboBox)
With drpdwn
.Caption = "Currency"
.AddItem "USD"
.AddItem "EUR"
.AddItem "JPY"
End With
Set cntrl = newbar.Controls.Add(msoControlButton)
With cntrl
.Caption = "Run FX"
.OnAction = "RunFX"
End With
newbar.Visible = True
End Sub
Function BarExists() As Boolean
On Error Resume Next
Dim cb As CommandBar
Set cb = CommandBars("Patrick")
BarExists = Err.Number = 0
On Error GoTo 0
End Function
Sub RunFX()
Dim ccy As String
' YOUR CODE HERE
If drpdwn Is Nothing Then SetMenuBar
If drpdwn.Text = "" Then
ccy = "*"
Else
ccy = drpdwn.Text
End If
End Sub


"Johan2000" wrote:

Is that possible to have an checkBox and/or ListBox on
the toolbar.... so the code bellow will be run if checkBox is check, and
listBox
pointing to currency...

Thank You

/ How to modify the content of the current Cell in Excel
// put this code in Excel/VisualBasic/MsProject/ExCellObject/Worksheet1
Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As String
x = Target.Value
If Right(x, 1) = "*" Then
Target.Value = Replace(x, "*", "000")
End If
End Sub



All times are GMT +1. The time now is 12:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com