【问题标题】:Excel VBA For Each select cell on breakExcel VBA For Each select cell on break
【发布时间】:2015-08-20 20:19:29
【问题描述】:

我有一个宏来检查任何空白单元格的范围,然后运行第二个宏。目前,如果找到空白单元格,用户会收到一条消息提醒他们有空白单元格,并且宏结束。

我希望能够在结束宏之前选择空白单元格,以便用户知道在哪里可以找到它。

Dim e As Range
Set e = Range("A2", Range("A1000").End(xlUp))

For Each Cell In e
    If IsEmpty(Cell) Then
        ActiveCell.Select
        MsgBox ("Please remove empty row")
        Cancel = True
        Application.StatusBar = vbNullString
        Exit Sub
    End If
Next

是否有一个选择器可以让空单元格保持活动状态?

【问题讨论】:

    标签: vba excel


    【解决方案1】:

    ActiveCell.Select 替换为Cell.Select

    【讨论】:

      【解决方案2】:

      试试这个....

      Sub test()
      Dim e As Range
      Set e = Range("A2", Range("A1000").End(xlUp))
      
      For Each Cell In e
          If IsEmpty(Cell) Then
              Cell.Select
              MsgBox ("Please remove empty row")
      
              Exit Sub
          End If
      Next
      
      
      End Sub
      

      【讨论】:

        猜你喜欢
        • 2014-05-23
        • 1970-01-01
        • 2015-05-15
        • 1970-01-01
        • 1970-01-01
        • 2021-08-08
        • 1970-01-01
        • 2015-10-27
        • 1970-01-01
        相关资源
        最近更新 更多