Is it possible to create "a thing" that shows for the user that some
vba codes are running?
For example, I have four vba codes and it takes a few minutes to
process, but the user can get confused if it is working or not.
Maybe you can make use the following. I have more familiarity with using
this code in a compiled VB program, but it seems to work okay on an Excel
spreadsheet. The code will change the cursor to the "busy" icon (the
spinning hourglass for Windows versions before Vista and that spinning
circle for Vista) before your code executes and back to the default icon
afterwards. Simply copy/paste the following into the applicable Worksheet
code window and call your macro (Sub Test() for this example) from the
spreadsheet itself (via Alt+F8 or as the assigned macro for a control, such
as a button, located on the sheet).
Private Declare Function LoadCursor Lib "user32" _
Alias "LoadCursorA" _
(ByVal hInstance As Long, _
ByVal lpCursorName As Long) As Long
Private Declare Function SetCursor Lib "user32" _
(ByVal hCursor As Long) As Long
Dim HoldCursor As Long ' Receives handle of default cursor
Dim NewCursor As Long ' Newly created cursor
Const IDC_WAIT = 32514&
Sub Test()
NewCursor = LoadCursor(ByVal 0&, IDC_WAIT)
HoldCursor = SetCursor(NewCursor)
'
' Your code goes here -- the MsgBox statement is just an example
'
MsgBox "Hello"
SetCursor HoldCursor
End Sub
Note: I am pretty sure that the spinning icon will only be spinning over the
spreadsheet itself (so if you pop a MessageBox, the cursor won't be busy
icon while over the MessageBox even though your code popped it up).
Rick