-1

我在 Excel 中有一个列,其中包含需要选择然后突出显示的单元格的地址。请在下面找到快照:

Col#   Row#     Corresponding Address 
8      1        $H$1
9      2        $I$2
10     3        $J$3
10     4        $J$4
9      5        $I$5
10     6        $J$6
10     7        $J$7
10     8        $J$8
11     9        $K$9
12     10       $L$10
12     11       $L$11
11     12       $K$12

例如,我需要选择单元格 $H$1 并突出显示它。

我想为大型矩阵自动执行此任务。这个任务的 vba 代码是什么?

非常感谢任何帮助

4

1 回答 1

0

You would need to loop through the Corresponding Address column and set, (assuming that you want the cell colour changed in order to highlight it) the Interior.Colour to a RGB value:

Dim x As Worksheet, y As Worksheet
Dim CtrA As Long
Set x = Worksheets("SheetName1")
Set y = Worksheets("SheetName2")
For CtrA = 2 To x.Rows.Count
    y.Range(x.Range("C" & CtrA)).Interior.Color = RGB(0, 255, 0)
Next

where x is a reference to the sheet containing the table in your question, and y is a reference to the sheet that contains the cells you want to highlight.

于 2013-08-29T03:46:59.390 回答