Hi,
I'm trying to link the EditBox value in a personal ribbon to a macro (file in attach). I'm a basic VBA user, the codes were found on internet and adapted, however something is missing and I have no clue!?
Anybody can help?
Thanks
cpmsimoes
Hi,
I'm trying to link the EditBox value in a personal ribbon to a macro (file in attach). I'm a basic VBA user, the codes were found on internet and adapted, however something is missing and I have no clue!?
Anybody can help?
Thanks
cpmsimoes
That's good for "a basic VBA user"
I think you over-complicated it: too many variables and 99% identical subs
I changed your CustomUI
and simplified your callbacks<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon> <tabs> <tab id="MyTab" label="Operators" > <group id="MyGroup" label="Group Operators"> <editBox id="EditBox" label="Without Label" onChange="SetNumberValue" sizeString="WWWWWW" showLabel="false"/> <box id="box1" boxStyle="horizontal"> <button id="bMultiply" label="X" size="normal" onAction="Action" /> <button id="bDivide" label="/" size="normal" onAction="Action" /> </box> <box id="box2" boxStyle="horizontal"> <button id="bAdd" label="+" size="normal" onAction="Action" /> <button id="bSubtract" label="-" size="normal" onAction="Action" /> </box> </group> </tab> </tabs> </ribbon> </customUI>
so give this a shotOption Explicit Public RibbonTextBox As String 'Callback for EditBox onChange Sub SetNumberValue(control As IRibbonControl, text As String) RibbonTextBox = text End Sub 'Callback for bMultiple, etc. onAction Sub Action(control As IRibbonControl) Dim xValue As Double Dim c As Range If Not TypeOf Selection Is Range Then Exit Sub If Not IsNumeric(RibbonTextBox) Then MsgBox "Error! The value entered '" & RibbonTextBox & " is NOT a NUMBER." Exit Sub End If xValue = CDbl(RibbonTextBox) For Each c In Selection.Cells If IsNumeric(c.Value) Then Select Case control.ID Case "bMultiply": c.Value = c.Value * xValue Case "bDivide": c.Value = c.Value / xValue Case "bAdd": c.Value = c.Value + xValue Case "bSubtract": c.Value = c.Value - xValue Case Else MsgBox control.ID & " not found" End Select End If Next c End Sub
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Wow! Thank you so much, Paul. It's working like I wanted. Great!!