PDA

View Full Version : Solved: Next cell any direction



peterwmartin
01-01-2007, 04:09 PM
Hi All
Can someone tell me how to move to the next cell in any direction. I have a calendar control to send its value to the active cell. However now with the use of command buttons would like to select the next cell.
Can it be done with vbkeyright left etc in program. So user can stay on the user form with the mouse.
Thanks

lucas
01-01-2007, 04:15 PM
Hi Peterwmartin,
Can you show us the code you are using to get the selected date into the active cell please?

peterwmartin
01-01-2007, 04:23 PM
Private Sub Calendar1_Click()
ActiveCell.Value = Calendar1.Value
End Sub

lucas
01-01-2007, 04:27 PM
This should offset the value one cell to the right.....if you have more questions please post back.

Private Sub Calendar1_Click()
ActiveCell.Offset(0, 1).Value = Calendar1.Value
End Sub

lucas
01-01-2007, 04:30 PM
One cell to the left:

Private Sub Calendar1_Click()
ActiveCell.Offset(0, -1).Value = Calendar1.Value
End Sub

lucas
01-01-2007, 04:32 PM
One row down and one cell to the left:

Private Sub Calendar1_Click()
ActiveCell.Offset(1, -1).Value = Calendar1.Value
End Sub

XLGibbs
01-01-2007, 05:20 PM
Hi All
So user can stay on the user form with the mouse.
Thanks

I am not sure I follow this. it sounds like you want them to click the calendar, but tab to the next part of the userform..

Let's say you want them to go to the text text box named for this example Textbox1
[VBA]
Private Sub Calendar1_Click()
ActiveCell.Offset(0, -1).Value = Calendar1.Value
TextBox1.SetFocus 'moves the cursor to TextBox1
End Sub

peterwmartin
01-01-2007, 06:23 PM
Lucas & XLGibbs
Thank you for your answers, It was not what I wanted. I may not have made that clear however what you did give me helped me get what I wanted
ActiveCell.Offset(0, 1).Select
thanks very much I did not know I could put active cell offset.

lucas
01-01-2007, 06:55 PM
Let us know if your still having any problems. Try to explain as clearly as possible what your trying to do so we can do our best to help you. If this thread is solved please mark it solved using the thread tools at the top of the page.