PDA

View Full Version : Automatically move cursor if value exist



gnod
04-11-2011, 03:12 AM
hi,
would like to know how do i move the cursor down if the value of A1 has data??

i will pass some value coming from different source and the destination will be A1, once it has a value it should go to A2, and so on..

thanks,

BrianMH
04-11-2011, 08:57 AM
I assume you mean the selection.

while activecell.value <> ""
activecell.offset(1,0).activate
wend

gnod
04-11-2011, 04:36 PM
thanks brianMH,
how do i apply your code in worksheet_change??

i made some research and use this code as a temporary solution
or is there a better way to implement it


Private Sub Worksheet_Change(ByVal Target As Range)
Dim CurCell As Range
Set CurCell = ActiveCell

Dim CurCellInA As Range
Set CurCellInA = Me.Columns("A").Cells(CurCell.Row)

If IsEmpty(CurCellInA.Offset(1, 0).Value) Then
CurCell.EntireColumn.Cells(CurCellInA.Row + 1).Select
Else
CurCell.EntireColumn.Cells(CurCellInA.Row + 1).Select
End If
End Sub