Excel VBA:调用LostFocus()后获取前一个单元格的范围

我如何获得Excel中的前一个单元格的范围? 我有一个combobox,通常我可以使用ActiveCell.Value = box.Value将其值填充到活动单元格(在ComboBox下)。 当我select了我的combobox的值并单击任何其他单元格时,我想将combobox的值写入到前一个单元格中,但是此代码将其写入到单击单元格中:

 Private Sub box_LostFocus() ActiveCell.Value = box.Value End Sub 

有任何想法吗?

如果在工作表代码中包含此项,则PreviousCell将始终是您select的上一个范围。

 Dim PreviousCell As Range Private Sub Worksheet_SelectionChange(ByVal Target As Range) ' Your code that uses PreviousCell should go in the if statement that makes sure PreviousCell has a value If Not PreviousCell Is Nothing Then Debug.Print PreviousCell.Address End If Set PreviousCell = Target ' This needs to be the last line of code. End Sub