开发者

VBA to move cursor down to next row that has a value in column A?

开发者 https://www.devze.com 2023-01-22 22:55 出处:网络
Column A has values in some rows, blank in others. I\'m in some other column. In the row I am in, column A is blank.

Column A has values in some rows, blank in others.

I'm in some other column. In the row I am in, column A is blank.

I would like a macro which will move my cursor 开发者_StackOverflow中文版down - remaining in the current column - until it is on a row where column A is not blank.

This seems easy, but I know no VBA. Any help?


Sub MoveDownBasedOnColumnA()

  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.End(xlDown).Row).Select
  Else
    CurCell.EntireColumn.Cells(CurCellInA.Row + 1).Select
  End If

End Sub


Sub a()
  i = ActiveCell.Row
  ret = i
  j = ActiveCell.Column
  While (Cells(i, 1).Value = "" And i < 16000)
    i = i + 1
  Wend
  If (i = 16000) Then i = ret
  Application.Goto Reference:=Cells(i, j)
 End Sub   

Controlled "runaway" when you are bellow the column A used cells limit

0

精彩评论

暂无评论...
验证码 换一张
取 消