0

大家好,我正在尝试创建一个模块搜索来检查特定单元格中的数字是否已经存在于我的任何工作表中,以及在哪里?

4

1 回答 1

1

怎么样:

Sub WhereIsIt()
    Dim v As Variant, sh As Worksheet
    Dim msg As String
    v = ActiveCell.Value
    msg = ActiveSheet.Name & "-" & ActiveCell.Address
    For Each sh In Sheets
        For Each cell In sh.UsedRange
            If cell.Value = v Then
                msg = msg & vbCrLf & sh.Name & "-" & cell.Address
            End If
        Next cell
    Next sh
    MsgBox msg
End Sub
于 2013-10-01T12:04:32.347 回答