Center on Scroll Area

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Center on Scroll Area

Post by Rudi »

Hi,

Is it possible to center on a scroll area?
The attached workbook runs a macro on sheet 1 that centers the range Z30 to AO30 on the screen width, but I'd also like to lock the scroll area so one cannot scroll past Z30:AO100. The two seem to conflict and debug is they are both in action. Any ideas?

TX

Workbook attached...
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78474
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Center on Scroll Area

Post by HansV »

You could use

Code: Select all

Private Sub Worksheet_Activate()
    ActiveSheet.ScrollArea = ""
    CenterOnCellND Range("Z30:AO30")
    ActiveSheet.ScrollArea = "$Z$30:$AQ$100"
End Sub
to avoid the conflict (which is caused by the argument .Scroll = True of Application.GoTo).
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Center on Scroll Area

Post by Rudi »

HA!!!
So simple....So elegant.... :censored:

TX
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.