Previously active cell

后端 未结 4 1872
闹比i
闹比i 2020-12-19 22:04

For the code I am writing I monitor the changes in certain cell ranges to run functions and private subs. For this I use the Intersect function in the worksheet_change

4条回答
  •  既然无缘
    2020-12-19 22:14

    With this code, referring PreviousActiveCell will return desired result:

    Public PreviousActiveCell as Range
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Static pPrevious as Range
        Set PreviousActiveCell = pPrevious
        Set pPrevious = ActiveCell
    End Sub
    

    This works inside single worksheet. Do you need a previous cell across other sheets and workbooks?

提交回复
热议问题