Forum Discussion
DylanBrown
Aug 12, 2024Copper Contributor
Auto-scroll an Excel workbook
Hi Guys, Looking for some assistance, I am hooking up a mini PC to a Samsung Smart TV to display an Excel spreadsheet, bascially highlights what projects we have on and some info in a table. ...
- Aug 13, 2024
DylanBrown It should continue to run just fine, the code looks at the current size of the table each time it runs.
JKPieterse
Aug 12, 2024Silver Contributor
DylanBrown You can do this with a bit of VBA code (paste into a normal module):
Option Explicit
Dim nextTime As Double
Sub scrollAgain()
Dim curVisLastRow As Long
curVisLastRow = ActiveWindow.VisibleRange(ActiveWindow.VisibleRange.Cells.Count).Row
With ActiveSheet.ListObjects(1)
If curVisLastRow < (.ListRows.Count + .Range.Cells(1, 1).Row) Then
ActiveWindow.SmallScroll Down:=1
Else
ActiveWindow.SmallScroll up:=curVisLastRow - 1
End If
End With
nextTime = Now + TimeValue("00:00:01")
Application.OnTime nextTime, "scrollAgain"
End Sub
Sub StopScrolling()
On Error Resume Next
Application.OnTime nextTime, "scrollAgain", , False
End Sub
Start the scrolling by running the scrollAgain macro (alt+F8 from Excel, click on macroname and hit Run).
Stop it by running StopScrolling.
To make this slower, adjust the "00:00:01"
By the way: the code assumes your table is "Formatted as table".
DylanBrown
Aug 12, 2024Copper Contributor
JKPieterse - Thanks for this, I've just tried to run this now but I get the below error. Do I need to change something in the code to suit my workbook?
- DylanBrownAug 12, 2024Copper ContributorAh nevermind, I didn't put it in a new module, that seems to be working now, thank you. Is there any risk of excel crashing if this is set to this permanent?
Also, we have this document in a shared library, so people will be adding data to it, if this is opened whilst people make amendments will it update live or will I need to add some VBA to update the doc every minute for example?
Thanks- JKPieterseAug 13, 2024Silver Contributor
DylanBrown It should continue to run just fine, the code looks at the current size of the table each time it runs.