Solved

Move to another cell

Posted on 2013-12-03
12
200 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
  • 6
  • 3
  • 3
12 Comments
 
LVL 32

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 32

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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 32

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

947 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now