animated stautus bar

seacrest

Active Member
Joined
Aug 15, 2002
Messages
301
I copied the following code from this site It works great but it runs continuously I would like it to run for about 10 seconds on
opening my spreadsheet. Can you help?




Public Sub animatestatusbar()

Dim sText As String
Dim iLength As Integer
Dim bForwards As Boolean


sText = "Hello"
iLength = Len(sText) + 1
bForwards = True

Do
DoEvents

If bForwards Then
sText = " " & sText
Else
sText = Right(sText, Len(sText) - 1)
End If

If Len(sText) > 30 Then
bForwards = False
End If

If Len(sText) < iLength Then
bForwards = True
End If
Sleep 300
Application.StatusBar = sText
Loop

End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
sorry i left this off the very top



Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
 
Upvote 0
The following amended will now work for approx 10 seconds.

Code:
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)


Public Sub animatestatusbar()

Dim sText As String
Dim iLength As Integer
Dim bForwards As Boolean


sText = "Hello"
iLength = Len(sText) + 1
bForwards = True
rep = 0

Do
DoEvents
rep = rep + 1
If bForwards Then
sText = " " & sText
Else
sText = Right(sText, Len(sText) - 1)
End If

If Len(sText) > 30 Then
bForwards = False
End If

If Len(sText) < iLength Then
bForwards = True
End If
Sleep 150
Application.StatusBar = sText
If rep > 50 Then GoTo break
Loop
break:
Application.StatusBar = ""
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,654
Messages
6,120,758
Members
448,991
Latest member
Hanakoro

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top