[RESOLVED] Excel addin with userform toolbar - Help with optimizing the interface!!
Hi there,
I am relatively new to Visual Basic coding but I have recently been working on an excel addin that has 9 different tasks to complete. They need to be completed in a specific order and for general cases some of them need to be repeated.
The main problem I have at the moment is that when my userform toolbox appears (I have made the addin automatically start when the workbook is opened) I cannot select the certain cells required for the macros to run. In some cases the user needs to be able to select different cells to troubleshoot or complete the different actions.
Is there a way to "pause" the macro after the Button has been pushed and then resume operations when the user selects the related cell? or Is there a way to allow users to interact with the spreadsheet even when the userform is displayed?
I'm sorry if this doesn't make sense, I'm finding it hard to explain.
Cheers
This is the code for the userform
Code:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If Button.Index = 1 Then
Application.Run "SetUp"
ElseIf Button.Index = 2 Then
Application.Run "OpenSIInp"
ElseIf Button.Index = 3 Then
Application.Run "OpenSIRPred"
ElseIf Button.Index = 4 Then
Application.Run "OpenSIJunc"
ElseIf Button.Index = 5 Then
Application.Run "OpenSILayer"
ElseIf Button.Index = 6 Then
Application.Run "SISum"
ElseIf Button.Index = 8 Then
Application.Run "OpenRoomDiagrams"
ElseIf Button.Index = 9 Then
Application.Run "OpenPath"
ElseIf Button.Index = 10 Then
Application.Run "HelpButton"
ElseIf Button.Index = 11 Then
Application.Run "RestoreToolbars"
End
End If
End Sub
Re: Excel addin with userform toolbar - Help with optimizing the interface!!
Excel VBA question moved to Office Development
Re: Excel addin with userform toolbar - Help with optimizing the interface!!
Quote:
or Is there a way to allow users to interact with the spreadsheet even when the userform is displayed?
yes, set a module level boolean variable, have the macro finish, then in the selection change event check which boolean is set (if any), set it to false and run other appropriate code based on which boolean
Re: Excel addin with userform toolbar - Help with optimizing the interface!!
Thanks for the quick reply.
I have seen a few people suggest the same thing in other threads but as I am fairly new to VB, I don't really know where to start in implementing the method.
Would you be able to post a generic example of what you are describing?
I have solved the problem by using 'vbModeless' elsewhere in my project (code below), would there be any potential problems by doing this?
There is another module which launches the userform (UserForm1) which contains the toolbar.
Code:
Sub launchtoolbar()
UserForm1.Show vbModeless
End Sub
This seems to have solved the problem and now the user can access the spreadsheet with the userform open.
Cheers