根据标准select不连续的单元格

我有一个字母“D”的电子表格,没有任何其他放置在随机单元格。 我使用哪些代码来select/复制 – 甚至更好地调暗范围 – 所有这些单元格?

到目前为止,我有以下几点:

Sub SelectD() Dim AllD As Range For Each cell In ActiveSheet.UsedRange.Cells If cell = "D" Then Set AllD = '??? End If Next cell End Sub 

谢谢,Bartek

使用联合将单元格添加到find的范围。

 Sub SelectD() Dim AllD As Range For Each cell In ActiveSheet.UsedRange.Cells If cell = "D" Then If AllD Is Nothing then Set AllD = cell Else Set AllD = Union(cell,AllD) End If End If Next cell 'Do something with AllD Debug.Print AllD.Address End Sub