checkBox & ListBox on ToolBar...

J

Johan2000

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
 
P

Patrick Molloy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top