How to determine if a worksheet Cell is Visible/Displayed in VBA?

后端 未结 2 1500
鱼传尺愫
鱼传尺愫 2020-12-19 01:40

I need to find if a cell is visible on the screen.

By visible, I don\'t mean hidden. I am specifically trying to find if a cell is currently displayed in the active

2条回答
  •  我在风中等你
    2020-12-19 02:10

    Here's a function that does what you want:

    Function CellIsInVisibleRange(cell As Range)
    CellIsInVisibleRange = Not Intersect(ActiveWindow.VisibleRange, cell) Is Nothing
    End Function
    

    At least I think it does. I hadn't been aware of the VisibleRange property until now.

    Call it like:

    If CellIsInVisibleRange(ActiveSheet.Range("A35")) Then
        MsgBox "Cell is visible"
    Else
        MsgBox "Cell isn't visible"
    End If
    

提交回复
热议问题