Forum Discussion
666_666666
May 25, 2023Copper Contributor
Conditional Formating copy VBA
I can't figure out how to copy conditional formatting rules
the task is to copy a rule (not a cell format, but a rule) from, for example, a file.xlsx (not necessarily this type, any format that supports storing conditional formatting rules is interested in)
and apply it to a previously opened workbook containing data ...
and all this must be done on VBA in excel 2016 (to support versions starting from 2016)
without connecting third-party libraries or using third-party applications (to avoid communicating with permissions)
everything I could find doesn't satisfy at least one concept
Please help
Copying only conditional formatting would be complicated.
Copying all formatting, including conditional formatting, is doable - copy the source range and paste special with xlPasteFormats to the target range. But if you have rules that refer to other cells than the ones being formatted, the result might be unpredictable.
- 666_666666Copper Contributor
I would like you to understand. there are no values in the cells of the file in which the rule is stored - conditional formatting in this case cannot be picked up by the Range method or any other method applicable to the cells
Formatting (including conditional formatting) can be copied/pasted regardless of whether a cell contains a value (or formula) or not...