VBA to determine if rows are visible on the screen?

Matty

Well-known Member
Joined
Feb 17, 2007
Messages
3,710
Hi All,

I'm after some code to test whether rows 1:7 and are rows 129:135 are visible on the screen. Since different screen sizes/resolutions show different things, I need this test to be carried out before further code executes.

Can anyone suggest how this could be done?

Thanks,

Matty
 

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"

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
37,883
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi All,

I'm after some code to test whether rows 1:7 and are rows 129:135 are visible on the screen. Since different screen sizes/resolutions show different things, I need this test to be carried out before further code executes.
Does all rows of those ranges have to be visible or would knowing if at least one row of those rows is visible be enough?
 

Matty

Well-known Member
Joined
Feb 17, 2007
Messages
3,710
Hi Rick,

If the test was just against row 1 and row 129, that'd be fine.

Thanks,

Matty
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
37,883
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi Rick,

If the test was just against row 1 and row 129, that'd be fine.
These lines of code will report True if Row 1 and Row 129 are visible, False otherwise...

IsRowOneVisible = Not Intersect(Rows(1), ActiveWindow.VisibleRange) Is Nothing

IsRow129Visible = Not Intersect(Rows(129), ActiveWindow.VisibleRange) Is Nothing
 

Matty

Well-known Member
Joined
Feb 17, 2007
Messages
3,710
Thank you, Rick. I will try out your suggestion.

Matty
 

Squirrel22

New Member
Joined
Jul 12, 2014
Messages
4
These lines of code will report True if Row 1 and Row 129 are visible, False otherwise...

IsRowOneVisible = Not Intersect(Rows(1), ActiveWindow.VisibleRange) Is Nothing

IsRow129Visible = Not Intersect(Rows(129), ActiveWindow.VisibleRange) Is Nothing
Rick, your solution is simple, that's is what I was looking. Many thanks.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,148
Messages
5,835,681
Members
430,375
Latest member
datdog22

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
Top