VBA to move the vba scroll bar up and down the page as rows are hidden

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,
not sure if this can be done but what I need is this.

I have a sheet with 800 rows
I have a scroll bar and I need to move it to the right position on the page.
so I need a macro that can count 100 rows from the top and move the scroll bar so the top of the bar is in row 100, except its not the actual 100th row it the 100th visable row
so for example if rows 99 to 199 are hidden then the 100th row is actually row 200.

hope that make sense, please help if you can

Tony
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Code:
Sub Scroll_100()
Dim rng As Range, cel As Range, c%
Set rng = [A:A].SpecialCells(xlCellTypeVisible)
For Each cel In rng
    c = c + 1
    If c = 100 Then
        With ActiveWindow
            .ScrollColumn = 1
            .ScrollRow = cel.Row
        End With
        Exit For
    End If
Next
End Sub
 
Upvote 0
Thank you footoo,
this is not quite what I was looking for but gave me the part I needed which was to find the 100th visible row.
Thank you so much problem now solved
Tony
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
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