Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default set cursor position after cell is populated??

If a user enters an integer value into say cell A1 and then presses the
Enter key, the cursor (or "active cell") will instantly move one cell
downwards, which I think is Excel's default behavior on spreadsheets.

Can I change this behavior using Visual Basic?? Basically, after a user
enters a value into an arbitrary cell and then presses the Enter key, I
would
like to program Excel to move the cursor or "active cell" to a cell of my
choice.

I hope this question makes sense. Please advise!

Thank you!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,480
Default set cursor position after cell is populated??

Hi Robert

Something like the following should work
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myrng As Range
Set myrng = Range("C3") '<--- Change to suit source cell
If Not Intersect(Target, myrng) Is Nothing Then
Range("H3").Activate ' <-- Change to suit destination required
End If
End Sub

--
Regards
Roger Govier

"Robert Crandal" wrote in message
...
If a user enters an integer value into say cell A1 and then presses the
Enter key, the cursor (or "active cell") will instantly move one cell
downwards, which I think is Excel's default behavior on spreadsheets.

Can I change this behavior using Visual Basic?? Basically, after a user
enters a value into an arbitrary cell and then presses the Enter key, I
would
like to program Excel to move the cursor or "active cell" to a cell of my
choice.

I hope this question makes sense. Please advise!

Thank you!



__________ Information from ESET Smart Security, version of virus
signature database 4536 (20091023) __________

The message was checked by ESET Smart Security.

http://www.eset.com




__________ Information from ESET Smart Security, version of virus signature database 4536 (20091023) __________

The message was checked by ESET Smart Security.

http://www.eset.com



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default set cursor position after cell is populated??

You can do this with a worksheet_Change event.

http://www.mvps.org/dmcritchie/excel/event.htm

"Robert Crandal" wrote:

If a user enters an integer value into say cell A1 and then presses the
Enter key, the cursor (or "active cell") will instantly move one cell
downwards, which I think is Excel's default behavior on spreadsheets.

Can I change this behavior using Visual Basic?? Basically, after a user
enters a value into an arbitrary cell and then presses the Enter key, I
would
like to program Excel to move the cursor or "active cell" to a cell of my
choice.

I hope this question makes sense. Please advise!

Thank you!


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default set cursor position after cell is populated??

Sub StopMovingAfterEnter()
Application.MoveAfterReturn = False
End Sub


"Robert Crandal" wrote:

If a user enters an integer value into say cell A1 and then presses the
Enter key, the cursor (or "active cell") will instantly move one cell
downwards, which I think is Excel's default behavior on spreadsheets.

Can I change this behavior using Visual Basic?? Basically, after a user
enters a value into an arbitrary cell and then presses the Enter key, I
would
like to program Excel to move the cursor or "active cell" to a cell of my
choice.

I hope this question makes sense. Please advise!

Thank you!


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default set cursor position after cell is populated??

in addition to my prev posting which just stopped the movement, you could use
the change event to control it ...here's some code that offers you some
ideas. right click the sheet tab and select View Code, then paste this:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Count = 1 Then
If Target.Column = 3 Then
Select Case Target.Value
Case Is < 10
Range("B3").Select
Case 11
Worksheets("sheet2").Activate
Worksheets("sheet2").Range("C5").Select
Case 14, 21, 28
Range("A7:D7").Select
Case Else
' do nothing
End Select

End If

End If


End Sub

"Robert Crandal" wrote:

If a user enters an integer value into say cell A1 and then presses the
Enter key, the cursor (or "active cell") will instantly move one cell
downwards, which I think is Excel's default behavior on spreadsheets.

Can I change this behavior using Visual Basic?? Basically, after a user
enters a value into an arbitrary cell and then presses the Enter key, I
would
like to program Excel to move the cursor or "active cell" to a cell of my
choice.

I hope this question makes sense. Please advise!

Thank you!


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default set cursor position after cell is populated??

Can I paste this code into ANY module in my Excel/Visual Basic code??
I only have one module ("Module 1"), in which I pasted this code exactly,
however it does NOT work. Am I missing something??

Sorry, I'm still a newbie at this Visual Basic for Excel stuff. thank you!
8)

"Roger Govier" <roger@technology4unospamdotcodotuk wrote in message
...
Hi Robert

Something like the following should work
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myrng As Range
Set myrng = Range("C3") '<--- Change to suit source cell
If Not Intersect(Target, myrng) Is Nothing Then
Range("H3").Activate ' <-- Change to suit destination required
End If
End Sub


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default set cursor position after cell is populated??

Ok... I pulled the code out of my "Module 1". I tried pasting the code into
my
"Sheet1" object area and the code worked fine. 8)

After I pasted your code, I noticed a popup message that stated
"Cannot perform the requested operation" or something similiar to that.
Oh well, I guess it's nothing to worry about, right?? The code actually
works, I was just wondering why I got that message. Oh, I wont worry about
it too much!

"Robert Crandal" wrote in message
...
Can I paste this code into ANY module in my Excel/Visual Basic code??
I only have one module ("Module 1"), in which I pasted this code exactly,
however it does NOT work. Am I missing something??

Sorry, I'm still a newbie at this Visual Basic for Excel stuff. thank
you! 8)


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,480
Default set cursor position after cell is populated??

Hi Robert

I'm sorry. I should have included my normal instructions on how to paste the
code into the Sheet area, as it is event code.
Glad you figured it out and did the right thing.
I don't understand the message you got.
If you wanted to mail me a copy of your workbook, I would be happy to see if
I can resolve the issue for you.
to mail direct
roger at technology4u dot co dot uk
Do the obvious with at and dot to make a valid email address.

--
Regards
Roger Govier

"Robert Crandal" wrote in message
...
Ok... I pulled the code out of my "Module 1". I tried pasting the code
into my
"Sheet1" object area and the code worked fine. 8)

After I pasted your code, I noticed a popup message that stated
"Cannot perform the requested operation" or something similiar to that.
Oh well, I guess it's nothing to worry about, right?? The code actually
works, I was just wondering why I got that message. Oh, I wont worry
about
it too much!

"Robert Crandal" wrote in message
...
Can I paste this code into ANY module in my Excel/Visual Basic code??
I only have one module ("Module 1"), in which I pasted this code exactly,
however it does NOT work. Am I missing something??

Sorry, I'm still a newbie at this Visual Basic for Excel stuff. thank
you! 8)



__________ Information from ESET Smart Security, version of virus
signature database 4537 (20091023) __________

The message was checked by ESET Smart Security.

http://www.eset.com




__________ Information from ESET Smart Security, version of virus signature database 4537 (20091023) __________

The message was checked by ESET Smart Security.

http://www.eset.com



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
First populated cell in row array/ Last populated cell in row arra Skyscan Excel Worksheet Functions 7 May 29th 08 05:20 PM
Default cursor/selected cell position after protecting Stilla Excel Worksheet Functions 0 December 8th 05 02:28 PM
Why does cursor move position in a cell I'm trying to edit? BrendaK Excel Discussion (Misc queries) 3 August 22nd 05 10:32 PM
Display cursor position in cell Regina Rodler Excel Programming 6 March 10th 05 09:08 PM
cursor position choice[_2_] Excel Programming 1 August 22nd 04 11:49 PM


All times are GMT +1. The time now is 07:17 PM.

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

About Us

"It's about Microsoft Excel"