excel - Can someone provide the technical reason why the `Interior.Color` property can't be assigned from one range to another in Excel VBA?
问题描述
I've seen this link describing using the clipboard to transfer formats (and this is probably what I'll end up having to do), but I'd like to know the technical reason why values can be assigned by reference and formats can't.
In other words, why does this work...
Sheets("Sheet2").Range("A1:B10").Value = Sheets("Sheet1").Range("D1:E10").Value
and this fail?...
Sheets("Sheet2").Range("A1:B10").Interior.Color = Sheets("Sheet1").Range("D1:E10").Interior.Color
解决方案
In short, Interior.Color
only returns one color, not an array of colors.
So this only works if the Interior.Color
is the same for all of the source target cells.
Since Interior.Color
doesn't return an array of differing colors, it will return 0
if the colors don't match across the source target cells.
推荐阅读
- ios - 类似于 Whatsapp 的读取状态的双重复选标记
- prestashop - Prestashop 单价小数配置
- powershell - 在 Hyper-v 2016 中远程使用 Move-VM 所需的权限
- android - SharedPreference 给了我未知的日志
- swift - 类型转换需要解包吗?
- vue.js - 如何通过全局设置覆盖 Emacs 包设置(脚本)(无需编辑包脚本)
- node.js - 通过 Redis 简单消息队列发送电子邮件
- java - 从字符串数组中获取整数列表
- angular - 只有第一个测试用例成功 - Angular 中的 Jasmine/Karma
- javascript - 电子 Js,拖放,JavaScript