PC Review


Reply
Thread Tools Rate Thread

Where best to place an instruction in a VBA script

 
 
Colin Hayes
Guest
Posts: n/a
 
      19th Jan 2010

Hi All

I'm using this code when I open my workbook.

Private Sub Workbook_Open()
Dim mysheets As Sheets
Set mysheets = Worksheets(Array(1))
For Each Sheet In mysheets
Sheets("ShareSheet").ScrollArea = "A1:J27"

Next


End Sub


I'd like cell A200 to be selected and have the cursor box on it on
opening the worksheet.

I'm trying to place this line in the code :

Application.Goto Reference:="R200C1"

but can't get it to work.

Can someone advise please?

Grateful for any assistance.


Best Wishes
 
Reply With Quote
 
 
 
 
FSt1
Guest
Posts: n/a
 
      19th Jan 2010
hi
Range("A200").select

Regards
FSt1

"Colin Hayes" wrote:

>
> Hi All
>
> I'm using this code when I open my workbook.
>
> Private Sub Workbook_Open()
> Dim mysheets As Sheets
> Set mysheets = Worksheets(Array(1))
> For Each Sheet In mysheets
> Sheets("ShareSheet").ScrollArea = "A1:J27"
>
> Next
>
>
> End Sub
>
>
> I'd like cell A200 to be selected and have the cursor box on it on
> opening the worksheet.
>
> I'm trying to place this line in the code :
>
> Application.Goto Reference:="R200C1"
>
> but can't get it to work.
>
> Can someone advise please?
>
> Grateful for any assistance.
>
>
> Best Wishes
> .
>

 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      19th Jan 2010
Try

Application.Goto Range("A200"), True

OR add this to the worksheet Activate event as below...

Private Sub Worksheet_Activate()
Application.Goto Range("A200"), True
End Sub

--
Jacob


"Colin Hayes" wrote:

>
> Hi All
>
> I'm using this code when I open my workbook.
>
> Private Sub Workbook_Open()
> Dim mysheets As Sheets
> Set mysheets = Worksheets(Array(1))
> For Each Sheet In mysheets
> Sheets("ShareSheet").ScrollArea = "A1:J27"
>
> Next
>
>
> End Sub
>
>
> I'd like cell A200 to be selected and have the cursor box on it on
> opening the worksheet.
>
> I'm trying to place this line in the code :
>
> Application.Goto Reference:="R200C1"
>
> but can't get it to work.
>
> Can someone advise please?
>
> Grateful for any assistance.
>
>
> Best Wishes
> .
>

 
Reply With Quote
 
Colin Hayes
Guest
Posts: n/a
 
      19th Jan 2010
In article <9645423C-9A15-4143-9C94-(E-Mail Removed)>, FSt1
<(E-Mail Removed)> writes
>hi
>Range("A200").select
>
>Regards
>FSt1
>


Hi

Ok thanks for getting back. That's fixed it now. Worked first time.



Best Wishes



>>
>> Hi All
>>
>> I'm using this code when I open my workbook.
>>
>> Private Sub Workbook_Open()
>> Dim mysheets As Sheets
>> Set mysheets = Worksheets(Array(1))
>> For Each Sheet In mysheets
>> Sheets("ShareSheet").ScrollArea = "A1:J27"
>>
>> Next
>>
>>
>> End Sub
>>
>>
>> I'd like cell A200 to be selected and have the cursor box on it on
>> opening the worksheet.
>>
>> I'm trying to place this line in the code :
>>
>> Application.Goto Reference:="R200C1"
>>
>> but can't get it to work.
>>
>> Can someone advise please?
>>
>> Grateful for any assistance.
>>
>>
>> Best Wishes
>> .
>>


 
Reply With Quote
 
Dana DeLouis
Guest
Posts: n/a
 
      19th Jan 2010
>>> I'm trying to place this line in the code :
>>> Application.Goto Reference:="R200C1"


Hi. I'm glad it's working. It was a little confusing because one can't
select A200 after restrinting the selection to A1:J27

> Worksheets(Array(1))


Unless I'm mistaken, this appears to only return 1 sheet.

>Goto Reference:="R200C1"


Just to mention...if you want to use numbers instead of strings,
consider the Cells Property.

Here's my best guess on the code you posted.
Just note that Worksheets(1) "could" be ShareSheet, and you can't select
A200 when the scroll area is restricted to A1:J27.

Sub Demo()
Dim MySheet
Set MySheet = Worksheets(1)
Application.Goto MySheet.Cells(200, 1)

'Note: You can't Select A200 on "ShareSheet"
Sheets("ShareSheet").ScrollArea = "A1:J27"
End Sub

= = = = = = =
HTH :>)
Dana DeLouis




On 1/19/2010 7:52 AM, Colin Hayes wrote:
> In article <9645423C-9A15-4143-9C94-(E-Mail Removed)>, FSt1
> <(E-Mail Removed)> writes
>> hi
>> Range("A200").select
>>
>> Regards
>> FSt1
>>

>
> Hi
>
> Ok thanks for getting back. That's fixed it now. Worked first time.
>
>
>
> Best Wishes
>
>
>
>>>
>>> Hi All
>>>
>>> I'm using this code when I open my workbook.
>>>
>>> Private Sub Workbook_Open()
>>> Dim mysheets As Sheets
>>> Set mysheets = Worksheets(Array(1))
>>> For Each Sheet In mysheets
>>> Sheets("ShareSheet").ScrollArea = "A1:J27"
>>>
>>> Next
>>>
>>>
>>> End Sub
>>>
>>>
>>> I'd like cell A200 to be selected and have the cursor box on it on
>>> opening the worksheet.
>>>
>>> I'm trying to place this line in the code :
>>>
>>> Application.Goto Reference:="R200C1"
>>>
>>> but can't get it to work.
>>>
>>> Can someone advise please?
>>>
>>> Grateful for any assistance.
>>>
>>>
>>> Best Wishes
>>> .
>>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
In multiprocessor,we can not assume instruction's order even in one thread? we must write synchronous instruction in every function? zjs Microsoft VC .NET 3 18th Aug 2008 04:57 PM
I need step by step instruction on how to create and place a Googl DaddysDomayns Microsoft Frontpage 3 25th Feb 2008 11:09 PM
Where do you go for instruction in Access VBA instruction? =?Utf-8?B?Q2hyaXMgSGF5ZXM=?= Microsoft Access VBA Modules 5 3rd May 2007 03:43 AM
Best source for instruction on using "ifthen" formulas in excel? =?Utf-8?B?SlNXIGZvcm11bGFz?= Microsoft Excel Worksheet Functions 1 13th Sep 2006 10:34 PM
Top Tips from the Gurus!...Place your best of the best tips here! Alpha Freeware 12 30th Dec 2005 08:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:51 PM.