PC Review


Reply
Thread Tools Rate Thread

Capture Screen Position

 
 
=?Utf-8?B?UGFpZ2U=?=
Guest
Posts: n/a
 
      13th Jun 2007
Have code (see below) where if user enters something in Cell O68, it puts the
same value in D21 and forces the cursor to remain at Cell O68 after cell
entry (in case they want to enter something else). The problem is that only
specific cells in the sheet are unlocked, so when the user enters a value in
O68, Excel goes to the next unlocked cell (which is A3) then back to O68 (the
target). This causes the screen position to move slightly; i.e., if the top
row before entry is 65, after the code runs, it always moves the screen so
the top row is 47. I need the screen to stay in the same spot. Have tried
all manner of screen updating = false and also changing the code so that
after entry the cursor doesn't move, but it still affects the screen
position. It's not that the screen is moving back and forth (as when screen
updating is true), but only that it is adjusting the scroll position
so-to-speak.

Can someone advise me what I'm doing wrong, or if there is a way to capture
the specific position of the screen before entry, so I can then return the
user to that spot after entry?

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
Range("D21").Value = Range("O68").Value
Target.Select
End If
End Sub
 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      13th Jun 2007
Paige,
Because you are changing a value, it is causing the Worksheet_Change event
to fire gain. Disable events for this change, then reset.

If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
Application.EnableEvents=false
Range("D21").Value = Range("O68").Value
Application.EnableEvents=true
Target.Select
End If

NickHK

"Paige" <(E-Mail Removed)> 级糶秎ン穝籇:A0B8E0EE-91A9-4A7E-BFBA-(E-Mail Removed)...
> Have code (see below) where if user enters something in Cell O68, it puts
> the
> same value in D21 and forces the cursor to remain at Cell O68 after cell
> entry (in case they want to enter something else). The problem is that
> only
> specific cells in the sheet are unlocked, so when the user enters a value
> in
> O68, Excel goes to the next unlocked cell (which is A3) then back to O68
> (the
> target). This causes the screen position to move slightly; i.e., if the
> top
> row before entry is 65, after the code runs, it always moves the screen so
> the top row is 47. I need the screen to stay in the same spot. Have
> tried
> all manner of screen updating = false and also changing the code so that
> after entry the cursor doesn't move, but it still affects the screen
> position. It's not that the screen is moving back and forth (as when
> screen
> updating is true), but only that it is adjusting the scroll position
> so-to-speak.
>
> Can someone advise me what I'm doing wrong, or if there is a way to
> capture
> the specific position of the screen before entry, so I can then return the
> user to that spot after entry?
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> Range("D21").Value = Range("O68").Value
> Target.Select
> End If
> End Sub



 
Reply With Quote
 
=?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?=
Guest
Posts: n/a
 
      13th Jun 2007
I'd try putting

Application.screenupdating = FALSE

at the beginning of your code and

Application.ScreenUpdating = TRUE

at the end of yoru code.

HTH,
Barb Reinhardt

"Paige" wrote:

> Have code (see below) where if user enters something in Cell O68, it puts the
> same value in D21 and forces the cursor to remain at Cell O68 after cell
> entry (in case they want to enter something else). The problem is that only
> specific cells in the sheet are unlocked, so when the user enters a value in
> O68, Excel goes to the next unlocked cell (which is A3) then back to O68 (the
> target). This causes the screen position to move slightly; i.e., if the top
> row before entry is 65, after the code runs, it always moves the screen so
> the top row is 47. I need the screen to stay in the same spot. Have tried
> all manner of screen updating = false and also changing the code so that
> after entry the cursor doesn't move, but it still affects the screen
> position. It's not that the screen is moving back and forth (as when screen
> updating is true), but only that it is adjusting the scroll position
> so-to-speak.
>
> Can someone advise me what I'm doing wrong, or if there is a way to capture
> the specific position of the screen before entry, so I can then return the
> user to that spot after entry?
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> Range("D21").Value = Range("O68").Value
> Target.Select
> End If
> End Sub

 
Reply With Quote
 
=?Utf-8?B?UGFpZ2U=?=
Guest
Posts: n/a
 
      13th Jun 2007
Unfortunately, neither of these work, individually or in combination. It
still moves the screen so that Row 47 is the first row showing. So I am left
with wondering if there is a way to capture where the screen is, so I can
return to that point; any ideas on that? Thanks for your help....

"NickHK" wrote:

> Paige,
> Because you are changing a value, it is causing the Worksheet_Change event
> to fire gain. Disable events for this change, then reset.
>
> If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> Application.EnableEvents=false
> Range("D21").Value = Range("O68").Value
> Application.EnableEvents=true
> Target.Select
> End If
>
> NickHK
>
> "Paige" <(E-Mail Removed)> 录露录g漏贸露l楼贸路s禄D:A0B8E0EE-91A9-4A7E-BFBA-(E-Mail Removed)...
> > Have code (see below) where if user enters something in Cell O68, it puts
> > the
> > same value in D21 and forces the cursor to remain at Cell O68 after cell
> > entry (in case they want to enter something else). The problem is that
> > only
> > specific cells in the sheet are unlocked, so when the user enters a value
> > in
> > O68, Excel goes to the next unlocked cell (which is A3) then back to O68
> > (the
> > target). This causes the screen position to move slightly; i.e., if the
> > top
> > row before entry is 65, after the code runs, it always moves the screen so
> > the top row is 47. I need the screen to stay in the same spot. Have
> > tried
> > all manner of screen updating = false and also changing the code so that
> > after entry the cursor doesn't move, but it still affects the screen
> > position. It's not that the screen is moving back and forth (as when
> > screen
> > updating is true), but only that it is adjusting the scroll position
> > so-to-speak.
> >
> > Can someone advise me what I'm doing wrong, or if there is a way to
> > capture
> > the specific position of the screen before entry, so I can then return the
> > user to that spot after entry?
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> > Range("D21").Value = Range("O68").Value
> > Target.Select
> > End If
> > End Sub

>
>
>

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      13th Jun 2007
Tools=>Options=>Edit Tab, uncheck Move selection after enter.

If you want to control it in code, turn on the macro recorder while you do
it manually to get the code. Note that you would have to make this change
before any change was made to the cell - not in the change event. Perhaps in
the selection change event.

You can always bet the visible range with ActiveWindow.VisibleRange

ActiveWindow.VisibleRange(1)

is the top left cell in the visible range. If you have freeze panes or
horizontal/vertical splits in place, it may be more complex.


--
Regards,
Tom Ogilvy


"Paige" wrote:

> Unfortunately, neither of these work, individually or in combination. It
> still moves the screen so that Row 47 is the first row showing. So I am left
> with wondering if there is a way to capture where the screen is, so I can
> return to that point; any ideas on that? Thanks for your help....
>
> "NickHK" wrote:
>
> > Paige,
> > Because you are changing a value, it is causing the Worksheet_Change event
> > to fire gain. Disable events for this change, then reset.
> >
> > If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> > Application.EnableEvents=false
> > Range("D21").Value = Range("O68").Value
> > Application.EnableEvents=true
> > Target.Select
> > End If
> >
> > NickHK
> >
> > "Paige" <(E-Mail Removed)> 录露录g漏贸露l楼贸路s禄D:A0B8E0EE-91A9-4A7E-BFBA-(E-Mail Removed)...
> > > Have code (see below) where if user enters something in Cell O68, it puts
> > > the
> > > same value in D21 and forces the cursor to remain at Cell O68 after cell
> > > entry (in case they want to enter something else). The problem is that
> > > only
> > > specific cells in the sheet are unlocked, so when the user enters a value
> > > in
> > > O68, Excel goes to the next unlocked cell (which is A3) then back to O68
> > > (the
> > > target). This causes the screen position to move slightly; i.e., if the
> > > top
> > > row before entry is 65, after the code runs, it always moves the screen so
> > > the top row is 47. I need the screen to stay in the same spot. Have
> > > tried
> > > all manner of screen updating = false and also changing the code so that
> > > after entry the cursor doesn't move, but it still affects the screen
> > > position. It's not that the screen is moving back and forth (as when
> > > screen
> > > updating is true), but only that it is adjusting the scroll position
> > > so-to-speak.
> > >
> > > Can someone advise me what I'm doing wrong, or if there is a way to
> > > capture
> > > the specific position of the screen before entry, so I can then return the
> > > user to that spot after entry?
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> > > Range("D21").Value = Range("O68").Value
> > > Target.Select
> > > End If
> > > End Sub

> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?UGFpZ2U=?=
Guest
Posts: n/a
 
      13th Jun 2007
Thanks everyone; will work on this some more with all the suggestions.

"Tom Ogilvy" wrote:

> Tools=>Options=>Edit Tab, uncheck Move selection after enter.
>
> If you want to control it in code, turn on the macro recorder while you do
> it manually to get the code. Note that you would have to make this change
> before any change was made to the cell - not in the change event. Perhaps in
> the selection change event.
>
> You can always bet the visible range with ActiveWindow.VisibleRange
>
> ActiveWindow.VisibleRange(1)
>
> is the top left cell in the visible range. If you have freeze panes or
> horizontal/vertical splits in place, it may be more complex.
>
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Paige" wrote:
>
> > Unfortunately, neither of these work, individually or in combination. It
> > still moves the screen so that Row 47 is the first row showing. So I am left
> > with wondering if there is a way to capture where the screen is, so I can
> > return to that point; any ideas on that? Thanks for your help....
> >
> > "NickHK" wrote:
> >
> > > Paige,
> > > Because you are changing a value, it is causing the Worksheet_Change event
> > > to fire gain. Disable events for this change, then reset.
> > >
> > > If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> > > Application.EnableEvents=false
> > > Range("D21").Value = Range("O68").Value
> > > Application.EnableEvents=true
> > > Target.Select
> > > End If
> > >
> > > NickHK
> > >
> > > "Paige" <(E-Mail Removed)> 录露录g漏贸露l楼贸路s禄D:A0B8E0EE-91A9-4A7E-BFBA-(E-Mail Removed)...
> > > > Have code (see below) where if user enters something in Cell O68, it puts
> > > > the
> > > > same value in D21 and forces the cursor to remain at Cell O68 after cell
> > > > entry (in case they want to enter something else). The problem is that
> > > > only
> > > > specific cells in the sheet are unlocked, so when the user enters a value
> > > > in
> > > > O68, Excel goes to the next unlocked cell (which is A3) then back to O68
> > > > (the
> > > > target). This causes the screen position to move slightly; i.e., if the
> > > > top
> > > > row before entry is 65, after the code runs, it always moves the screen so
> > > > the top row is 47. I need the screen to stay in the same spot. Have
> > > > tried
> > > > all manner of screen updating = false and also changing the code so that
> > > > after entry the cursor doesn't move, but it still affects the screen
> > > > position. It's not that the screen is moving back and forth (as when
> > > > screen
> > > > updating is true), but only that it is adjusting the scroll position
> > > > so-to-speak.
> > > >
> > > > Can someone advise me what I'm doing wrong, or if there is a way to
> > > > capture
> > > > the specific position of the screen before entry, so I can then return the
> > > > user to that spot after entry?
> > > >
> > > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > > If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> > > > Range("D21").Value = Range("O68").Value
> > > > Target.Select
> > > > End If
> > > > End Sub
> > >
> > >
> > >

 
Reply With Quote
 
=?Utf-8?B?R1M=?=
Guest
Posts: n/a
 
      13th Jun 2007
Hi Paige,

Add this to your code:

Dim lLeft As Long, lTop As Long

lLeft = ActiveWindow.ScrollColumn
lTop = ActiveWindow.ScrollRow
ActiveWindow.ScrollIntoView lLeft, lTop, 1, 1
'Use 1 for the width and height argument..
'(It safely defaults to the screen width and height)

Leave ScreenUpdating off. Note that it will automatically reset when your
code terminates (if no other sub/function is running that also has it turned
off), so you don't need to explicitly turn it back on unless it's absolutely
necessary.

hth
Garry

"Paige" wrote:

> Unfortunately, neither of these work, individually or in combination. It
> still moves the screen so that Row 47 is the first row showing. So I am left
> with wondering if there is a way to capture where the screen is, so I can
> return to that point; any ideas on that? Thanks for your help....
>
> "NickHK" wrote:
>
> > Paige,
> > Because you are changing a value, it is causing the Worksheet_Change event
> > to fire gain. Disable events for this change, then reset.
> >
> > If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> > Application.EnableEvents=false
> > Range("D21").Value = Range("O68").Value
> > Application.EnableEvents=true
> > Target.Select
> > End If
> >
> > NickHK
> >
> > "Paige" <(E-Mail Removed)> 录露录g漏贸露l楼贸路s禄D:A0B8E0EE-91A9-4A7E-BFBA-(E-Mail Removed)...
> > > Have code (see below) where if user enters something in Cell O68, it puts
> > > the
> > > same value in D21 and forces the cursor to remain at Cell O68 after cell
> > > entry (in case they want to enter something else). The problem is that
> > > only
> > > specific cells in the sheet are unlocked, so when the user enters a value
> > > in
> > > O68, Excel goes to the next unlocked cell (which is A3) then back to O68
> > > (the
> > > target). This causes the screen position to move slightly; i.e., if the
> > > top
> > > row before entry is 65, after the code runs, it always moves the screen so
> > > the top row is 47. I need the screen to stay in the same spot. Have
> > > tried
> > > all manner of screen updating = false and also changing the code so that
> > > after entry the cursor doesn't move, but it still affects the screen
> > > position. It's not that the screen is moving back and forth (as when
> > > screen
> > > updating is true), but only that it is adjusting the scroll position
> > > so-to-speak.
> > >
> > > Can someone advise me what I'm doing wrong, or if there is a way to
> > > capture
> > > the specific position of the screen before entry, so I can then return the
> > > user to that spot after entry?
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Not Application.Intersect(Target, Range("O68")) Is Nothing Then
> > > Range("D21").Value = Range("O68").Value
> > > Target.Select
> > > End If
> > > End Sub

> >
> >
> >

 
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
Excel screen capture to capture cells and row and column headings jayray Microsoft Excel Misc 5 2nd Nov 2007 11:01 PM
Position of CellCursor on Screen (absolute position) newsgroups@joerg-lensing.de Microsoft Excel Programming 1 23rd Nov 2005 02:23 AM
Looking for a capture device that can capture EVERYTHING on my computer screen. Jeff Ingram Windows XP Video 2 11th Mar 2005 03:34 AM
Looking for a capture device that can capture computer screen. Jeff Ingram ATI Video Cards 5 7th Mar 2005 05:50 AM
Capture mouses X &Y position on a worksheet Stewart Microsoft Excel Programming 2 6th May 2004 06:37 PM


Features
 

Advertising
 

Newsgroups
 


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