【问题标题】:VBA to move cursor down to next row that has a value in column A?VBA将光标向下移动到A列中有值的下一行?
【发布时间】:2010-11-03 01:50:48
【问题描述】:

A 列在某些行中有值,在其他行中为空白。

我在一些 other 列。在我所在的行中,A 列是空白的。

我想要一个宏,它将我的光标向下移动 - 保留在当前列中 - 直到它位于 A 列为空白的行上。

这看起来很简单,但我不知道 VBA。有什么帮助吗?

【问题讨论】:

    标签: excel vba


    【解决方案1】:
    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
    

    【讨论】:

    • 这抛出了“'me'关键字的无效使用”......但我摆脱了'Me'。现在它可以工作了!非常感谢!
    • @dmd: 那是因为你把它放在一个模块中,而我的意思是它放在一个工作表中,其中Me 代表代码所在的工作表。没有Me 它意味着“在活动工作表上”,这可能就是您想要的。
    【解决方案2】:
    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   
    

    当您低于 A 列使用的单元格限制时,控制“失控”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多