Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to restrict scroll area

I have found Worksheets(1).ScrollArea to restrict viewing areas but it will
only work with static A1 style of referencing cells.

I required code to the effect that the scroll area is restricted but
dynamically, since I cannot know the limits of the area beforehand.

Any hel will be appreciated.
--
Regards,

CyberBuzzard
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default How to restrict scroll area

"CyberBuzzard" wrote:
I have found Worksheets(1).ScrollArea to restrict viewing areas but it will
only work with static A1 style of referencing cells.

I required code to the effect that the scroll area is restricted but
dynamically, since I cannot know the limits of the area beforehand.


Can't you dynamically generate an A1-style reference for the scroll area,
then pass it to ScrollArea?

Tell us what you've tried.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to restrict scroll area

I used ActiveCell.AddressLocal to obtain the Upper Left and Lower Right
cells of the area of interest.

Then I tried this:

FirstString = Assumptions.Range("Msg1").Text 'Contains first
address.
SecondString = Assumptions.Range("Msg2").Text 'Contains second address.
ThirdString = ":"
FourthString = """"
NewString = FourthString & Assumptions.Range("Msg1").Text & ThirdString
& _
Assumptions.Range("Msg2").Text & FourthString
Assumptions.Range("Msg2").Offset(2, 0) = NewString 'Enter in new cell.

Worksheets(1).ScrollArea = FourthString & Assumptions.Range("Msg1").Text
& ThirdString & _
Assumptions.Range("Msg2").Text & FourthString

I used a MsgBox to view the result and the text was fine but to no avail, I
always get the "Application-defined or object-defined error".

Can you see any errors in my code? I initially used the name of the
worksheet but also failed, though I'm sure that's not the source of the error
message.

"Shawn O'Donnell" wrote:

"CyberBuzzard" wrote:
I have found Worksheets(1).ScrollArea to restrict viewing areas but it will
only work with static A1 style of referencing cells.

I required code to the effect that the scroll area is restricted but
dynamically, since I cannot know the limits of the area beforehand.


Can't you dynamically generate an A1-style reference for the scroll area,
then pass it to ScrollArea?

Tell us what you've tried.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to restrict scroll area

Don't use addresslocal in VBA.
Rather than using string and concatenating, use the ranges themselves

Dim rng1 as Range, rng2 as Range, rng as Range
' code that determines upper left and activates it
set rng1 = ActiveCell
' code that determines lower right and activates cell
set rng2 = ActiveCell
set rng = Range(rng1,rng2)

Worksheets(1).ScrollArea = rng.Address

--
Regards,
Tom Ogilvy

"CyberBuzzard" wrote in message
...
I used ActiveCell.AddressLocal to obtain the Upper Left and Lower Right
cells of the area of interest.

Then I tried this:

FirstString = Assumptions.Range("Msg1").Text 'Contains first
address.
SecondString = Assumptions.Range("Msg2").Text 'Contains second

address.
ThirdString = ":"
FourthString = """"
NewString = FourthString & Assumptions.Range("Msg1").Text &

ThirdString
& _
Assumptions.Range("Msg2").Text & FourthString
Assumptions.Range("Msg2").Offset(2, 0) = NewString 'Enter in new

cell.

Worksheets(1).ScrollArea = FourthString &

Assumptions.Range("Msg1").Text
& ThirdString & _
Assumptions.Range("Msg2").Text & FourthString

I used a MsgBox to view the result and the text was fine but to no avail,

I
always get the "Application-defined or object-defined error".

Can you see any errors in my code? I initially used the name of the
worksheet but also failed, though I'm sure that's not the source of the

error
message.

"Shawn O'Donnell" wrote:

"CyberBuzzard" wrote:
I have found Worksheets(1).ScrollArea to restrict viewing areas but it

will
only work with static A1 style of referencing cells.

I required code to the effect that the scroll area is restricted but
dynamically, since I cannot know the limits of the area beforehand.


Can't you dynamically generate an A1-style reference for the scroll

area,
then pass it to ScrollArea?

Tell us what you've tried.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default How to restrict scroll area

"CyberBuzzard" wrote:
Then I tried this:

<snip

That almost would have worked--if you had used the .Address property of the
Range objects rather than the .Text property. .Text gives you the contents
of the cells. The other problem was that you don't need to put quotes on
strings you're constructing, unless you want the quote as part of the string.
You didn't want to do that here. When you're manually entering an A1-style
address, you need the quotes to tell the VB interpreter "this is a string,
don't interpret it as a variable name." When you pass an address in a String
variable, the interpreter won't evaluate the String further.

C2 = "A1"
Range(C2).Select

You'll be surprised which cell that will select if you don't read carefully.


In any case, do as Tom suggests and use the ranges themselves. So long as
you've figured out which cells to name Msg1 and Msg2, you could say:

Worksheets(1).ScrollArea = Range("Msg1", "Msg2").Address



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scroll Area Paul Dusterhoft Excel Discussion (Misc queries) 8 September 21st 05 11:36 AM
Restrict Scroll Area anuradha Excel Discussion (Misc queries) 0 July 20th 05 07:37 AM
How do I restrict any one not to scroll more than 100 row? Saadi Excel Worksheet Functions 1 January 7th 05 07:25 PM
Scroll Area Ashman Excel Programming 3 September 18th 04 04:23 PM
how to set scroll area David W[_3_] Excel Programming 1 August 26th 03 04:56 PM


All times are GMT +1. The time now is 02:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"