使用excel vba删除地址在另一个单元格中的单元格

时间:2013-07-04 03:17:06

标签: excel-vba vba excel

我需要使用excel宏删除一个单元格,其中该单元格的地址是另一个单元格中的文本。我需要代码非常简单,因为我几乎是一个完整的初学者。

1 个答案:

答案 0 :(得分:0)

够简单吗?

Sub Whipe()
Dim RAddress As Range, RAdrCell As Range
Dim RWhipe As Range, RWhipeCell As Range

    Set RAddress = Range([A1], [F6]) ' range containing the addresses
    Set RWhipe = Range([A7], [F12])  ' range containing data to be whiped

    For Each RWhipeCell In RWhipe.Cells
        For Each RAdrCell In RAddress.Cells
            If RWhipeCell.Address(False, False) = RAdrCell Then
                RWhipeCell = ""
            End If
        Next RAdrCell
    Next RWhipeCell
End Sub

enter image description here

enter image description here