首页 > 解决方案 > 遍历 excel 单元格范围并模拟两者的颜色填充

问题描述

在使用 VBA 的 excel 中,我正在编写一个以 2 列(或单元格区域)作为参数的公式。遍历参数的每个单元格,并将第一个参数的单元格填充/颜色分配给第二个参数中的相邻(同一行)单元格。这就是我所拥有的

Public Function ColoredCol(sourceCol As Range, destCol As Range)
    For n = destCol.Row To destCol.Rows.Count
        destCol(n, destCol.Column).Interior.ColorIndex =sourceCol(n, sourceCol.Column).Interior.ColorIndex
    Next

End Function

标签: excelvbabackground-colorfill

解决方案


推荐阅读