Scrolling Macro

Hart

Board Regular
Joined
Jan 2, 2005
Messages
78
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have created a macro which scrolls through a worksheet a fixed number of rows and then returns to the top and scrolls again. I need the "fixed" (14 in the sample below) number of rows to be variable based on the row number of a cell which contains specific text : "Today is"
Here is the macro..
Sub Scroll_Start()
NextTime = Now + TimeValue("00:00:02") 'Two second interval
ActiveWindow.Zoom = 125
Application.DisplayFullScreen = True
If ActiveWindow.VisibleRange.Rows(1).Row < 14 Then
ActiveWindow.SmallScroll Down:=1
Else
ActiveWindow.ScrollRow = 1
End If
Application.OnTime NextTime, "Scroll_Start"
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi, Assuming the "Today is" in column A you could try the following.


Sub CountRows()


Dim iRows As Integer

Range("A1").Select
Columns("A:A").Find(What:="Today is", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Activate
iRows = ActiveCell.Row


Scroll_Start (iRows)

End Sub


Then change your Sub statement to
Sub Scroll_Start(iRows As Integer)


And finally change the 14 with iRows


Hope this helps
 
Last edited:
Upvote 0
Hi, Assuming the "Today is" in column A you could try the following.


Sub CountRows()


Dim iRows As Integer

Range("A1").Select
Columns("A:A").Find(What:="Today is", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Activate
iRows = ActiveCell.Row


Scroll_Start (iRows)

End Sub


Then change your Sub statement to
Sub Scroll_Start(iRows As Integer)


And finally change the 14 with iRows


Hope this helps.

Hi Ray,
Thanks for your reply. This appears to be close however I am getting an error message - Argument not optional. It may be that I haven't properly completed your instructions so have copied and pasted what I have below..

Sub CountRows()


Dim iRows As Integer

Range("A1").Select
Columns("A:A").Find(What:="Today is", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Activate
iRows = ActiveCell.Row - 6


Scroll_Start (iRows)

End Sub

Sub Scroll_Start(iRows)
NextTime = Now + TimeValue("00:00:02") 'Two second interval
If ActiveWindow.VisibleRange.Rows(1).Row < iRows Then
ActiveWindow.SmallScroll Down:=1
Else
ActiveWindow.ScrollRow = 1
End If
Application.OnTime NextTime, "Scroll_Start"
End Sub
 
Upvote 0
Hi, Assuming the "Today is" in column A you could try the following.


Sub CountRows()


Dim iRows As Integer

Range("A1").Select
Columns("A:A").Find(What:="Today is", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Activate
iRows = ActiveCell.Row


Scroll_Start (iRows)

End Sub


Then change your Sub statement to
Sub Scroll_Start(iRows As Integer)


And finally change the 14 with iRows


Hope this helps.

Hi Ray,
Thanks for your reply. This appears to be close however I am getting an error message - Argument not optional. It may be that I haven't properly completed your instructions so have copied and pasted what I have below..

Sub CountRows()


Dim iRows As Integer

Range("A1").Select
Columns("A:A").Find(What:="Today is", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Activate
iRows = ActiveCell.Row - 6


Scroll_Start (iRows)

End Sub

Sub Scroll_Start(iRows)
NextTime = Now + TimeValue("00:00:02") 'Two second interval
If ActiveWindow.VisibleRange.Rows(1).Row < iRows Then
ActiveWindow.SmallScroll Down:=1
Else
ActiveWindow.ScrollRow = 1
End If
Application.OnTime NextTime, "Scroll_Start"
End Sub



Hi,

Looks like you've missed the "As Integer" option from the Sub statement

Sub Scroll_Start(iRows As Integer)


Ray
 
Upvote 0
Hi,

Looks like you've missed the "As Integer" option from the Sub statement

Sub Scroll_Start(iRows As Integer)


Ray


Hi Ray;
I am still getting that message "Argument is not optional". Thanks for your help!

Sub CountRows()


Dim iRows As Integer

Range("A1").Select
Columns("A:A").Find(What:="Today is", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False).Activate
iRows = ActiveCell.Row - 6


Scroll_Start (iRows)

End Sub

Sub Scroll_Start(iRows As Integer)

NextTime = Now + TimeValue("00:00:02") 'Two second interval
ActiveWindow.Zoom = 125
Application.DisplayFullScreen = True
If ActiveWindow.VisibleRange.Rows(1).Row < iRows Then
ActiveWindow.SmallScroll Down:=1
Else
ActiveWindow.ScrollRow = 1
End If
Application.OnTime NextTime, "Scroll_Start"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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