Private Sub CommandButton1_Click() Dim BmCell As Range If TextBValue = "" Then MsgBox "请输入所要查询的编码" Exit Sub End If With Worksheets("刀具信息") value = "" For Each BmCell In Range("L2:L" & Range("l65536")End(xlUp)Row) If CStr(BmCell) = TextBValue Then '下一行if判断中返回查到相同编码的单元格地址如果有多个单元格地址用","隔开 If Value = "" Then Value = BmCAddress(0, 0) Else Value = Value & "," & BmCAddress(0, 0) End If End If Next End WithEnd Sub