Solved

Move to another cell

Posted on 2013-12-03
12
204 Views
Last Modified: 2013-12-03
Folks,
In cell O2 I enter this formula =TODAY() and press <Enter> and then I want to go to Range("L3"). I've tried =if range("O2")<>"" then Range ("L3") but I do not know if it is correct or where to place the code?
0
Comment
Question by:Frank Freese
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
12 Comments
 
LVL 33

Expert Comment

by:Rob Henson
ID: 39692858
This code will move the cursor from O2 to L3 after O2 is changed.

Private Sub Worksheet_Change(ByVal Target As Range)

If ActiveCell.Row = 2 And ActiveCell.Column = 15 Then Range("L3").Select

End Sub

To implement, right click on the sheet tab and select view code, copy and paste the above into the right hand side of the VB Editor.

Thanks
Rob H
0
 
LVL 33

Assisted Solution

by:Rob Henson
Rob Henson earned 250 total points
ID: 39692870
Looking at the bigger picture, what are you trying to achieve? A similar result is possible without VBA.

If the sheet is protected, O2 is unlocked and L3 is the next available unlocked cell and move on enter is activated, the cursor will go to the next available cell.

Thanks
Rob H
0
 

Author Comment

by:Frank Freese
ID: 39692876
Hmmm...you second comment is applicable also.
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:Frank Freese
ID: 39692924
Neither of your suggestions worked? Attached is my file.
Locked-cells-Revised.xlsm
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 250 total points
ID: 39692955
Use

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("o2").Address Then
If Target <> "" Then Range("L3").Select
End If

End Sub
0
 

Author Comment

by:Frank Freese
ID: 39692964
Rob,
whoops! the second alternative worked fine. I forgot I had one cell left unprotected.I still would like a "shooting soultion" in VBA though. I tried your and that did not work, for me.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39692974
Did you try the code I gave?
0
 

Author Closing Comment

by:Frank Freese
ID: 39692986
thanks folks - I've got it now.
0
 

Author Comment

by:Frank Freese
ID: 39693064
ssaqibh,
Yes your code worked fine. Appreciate it!
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 39693151
@ssaqibh - do you have any suggestions why mine did not work when it basically does the sames as yours?
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39693162
Hi, Rob, you should have used target instead of activecell.
0
 

Author Comment

by:Frank Freese
ID: 39693205
thanks for the follow up. The part of Rob's answer I accepted was "If the sheet is protected, O2 is unlocked and L3 is the next available unlocked cell and move on enter is activated, the cursor will go to the next available cell."
I found a cell that was left unlocked when it should not have been and once I corrected that problem Rob's suggestion worked. However, the code was needed also.
Great job folks!
Frank
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question