Excel 如何通过VBA中的.find函数将变量设置为地址?
这里是我现在所拥有的一个片段。ListBoxAsset是从listbox中选择的内容。现在,它在第一个offset/delete行上抛出一个错误91。非常感谢任何帮助或反馈Excel 如何通过VBA中的.find函数将变量设置为地址?,excel,vba,Excel,Vba,这里是我现在所拥有的一个片段。ListBoxAsset是从listbox中选择的内容。现在,它在第一个offset/delete行上抛出一个错误91。非常感谢任何帮助或反馈 Private Sub CommandButton2_Click() Dim assetName As Long assetName = ListBoxAsset.Value Dim rgFound As Range Set rgFound = Range("B4:B18").Find(assetName) Dim
Private Sub CommandButton2_Click()
Dim assetName As Long
assetName = ListBoxAsset.Value
Dim rgFound As Range
Set rgFound = Range("B4:B18").Find(assetName)
Dim assetLoc As Range
If Not rgFound Is Nothing Then assetLoc = rgFound.Address
assetLoc.Offset(0, 0).Delete (xlShiftUp)
assetLoc.Offset(0, 1).Delete (xlShiftUp)
assetLoc.Offset(0, 2).Delete (xlShiftUp)
Unload Me
End Sub
你到底想做什么?你根本不想在这里使用
地址
——这是一个字符串
rgFound.Resize(,3).删除xlShiftUp