• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Scrolling message display in Excel

I want to display scrolling messages in dashboard. For eg... For example, In cell E1 it might say 'Sales are up by 11%'. I need the message to keep scrolling from Right-Left in Cell E1.
 
Code:
Option Explicit
'This form demos a Marquee (moving word Sign). Put your message in the selected Cell,
'Make sure you have at least 1 trailing space to seperate your rolling text.
'The default cell for this demo, is a Named cell called 'Marquee'. You can just pass
'the routine as cell or range address such as Cells(1,1) or Range("A1").
Public gsngSpeed As Single 'Speed value, should be in Seconds pause, but really varries.

Public Sub RunMarquee()
'There is no timer control in VBA excel, there is a timer function that returns the number of
'seconds since midnight. Weird, but workable.

Dim sngStart As Single
Dim sngPausetime As Single

On Error Resume Next

'Application.WindowState = xlMaximized

sngStart = Timer  ' Set start time. No. of seconds since midnight

StartHere:
sngPausetime = gsngSpeed
'following will pause 1 second
Do While Timer < sngStart + sngPausetime
    DoEvents    ' Yield to other processes.
Loop
 
'Now run the marquee
Call CellMarquee(Range("Marquee")) 'put in your own range here, like Cells(1,1) or Range("A1") etc.
   
sngStart = Timer
GoTo StartHere

End Sub

Private Sub CellMarquee(rng As Range)
'Set what you want displayed in the cell, should have at least 1 trailing space.
Dim buffer As String
buffer = rng.Value
If Len(buffer) > 1 Then
  rng.Value = Mid$(buffer, 2) & Left$(buffer, 1)
End If

End Sub
 

Attachments

  • MarqueeInCell.xls
    40 KB · Views: 33
Back
Top