• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Move to another cell

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
Frank Freese
Asked:
Frank Freese
  • 6
  • 3
  • 3
2 Solutions
 
Rob HensonFinance AnalystCommented:
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
 
Rob HensonFinance AnalystCommented:
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
 
Frank FreeseAuthor Commented:
Hmmm...you second comment is applicable also.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Frank FreeseAuthor Commented:
Neither of your suggestions worked? Attached is my file.
Locked-cells-Revised.xlsm
0
 
Saqib Husain, SyedEngineerCommented:
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
 
Frank FreeseAuthor Commented:
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
 
Saqib Husain, SyedEngineerCommented:
Did you try the code I gave?
0
 
Frank FreeseAuthor Commented:
thanks folks - I've got it now.
0
 
Frank FreeseAuthor Commented:
ssaqibh,
Yes your code worked fine. Appreciate it!
0
 
Rob HensonFinance AnalystCommented:
@ssaqibh - do you have any suggestions why mine did not work when it basically does the sames as yours?
0
 
Saqib Husain, SyedEngineerCommented:
Hi, Rob, you should have used target instead of activecell.
0
 
Frank FreeseAuthor Commented:
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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 6
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now