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
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,680
Office Version
  1. 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
36,680
Office Version
  1. 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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,519
Messages
5,596,634
Members
414,082
Latest member
sasmita

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