【发布时间】:2019-11-25 17:04:32
【问题描述】:
在我的 Excel 工作簿中,我将单个单元格设为命名范围。我没有使用 vba 来执行此操作,而是在 Excel 中转到Formulas > Name_Manager > New。我现在想在我正在编写的宏中引用这个命名范围。如果该单元格的背景颜色与我的命名范围匹配,该宏将复制该单元格的颜色。
当我在以下代码中将单元格的位置称为 Range("S2") 时,我的宏当前运行良好:
Trans_ECO_Row.Cells(, 13).Value = Trans_Queue_Row.Cells(, 14).Value
If Trans_Queue_Row.Cells(, 14).Interior.Color = QueueSheet.Range("S2").Interior.Color Then
Trans_ECO_Row.Cells(, 13).Interior.Color = Trans_Queue_Row.Cells(, 14).Interior.Color
End If
但是,我通过在 Excel 中转到 Formulas > Name_Manager > New 将单元格 S2 命名为 MGRColor。如何在上面的代码中将 S2 替换为 MGRColor?
【问题讨论】:
标签: excel vba named-ranges