简体   繁体   English

Excel宏以逐行复制和粘贴格式,而不是单元格范围

[英]Excel Macro to Copy and Paste Format Line by Line instead of range of cells

I am using conditional formatting in Excel 2007 to compare values row by row in cells H, K and U. 我在Excel 2007中使用条件格式来逐行比较单元格H,K和U中的值。

Since I am trying to use the conditional fomartting row by row instead of a range of cells. 由于我试图逐行使用条件fomarting,而不是一定范围的单元格。 My hand cramped up by row 50, and I have another few hundreds to go. 我的手被第50行收紧了,还有几百个要走。

Is there a macro that would check the rows and paste the format without having to do one at a time? 是否有一个宏可以检查行并粘贴格式,而不必一次执行一个宏?

A million thanks. 一百万个谢谢。

You don't need to apply the conditional formatting row-by-row. 您无需逐行应用条件格式。 If you use the proper combination of relative and absolute references in your conditional formatting formula, you can do it all in one shot. 如果在条件格式公式中使用相对引用和绝对引用的正确组合,则可以一次完成所有操作。 For example, select A1:C10 and enter this formula for conditional formatting 例如,选择A1:C10并输入此公式进行条件格式设置

=$A1=1 = $ A1 = 1

Because I made the column absolute with the dollar sign, every cell in A1:C10 will refer to column A. But since the row is relative, every cell will refer to column A on its same row. 因为我用美元符号使列绝对,所以A1:C10中的每个单元格都将引用A列。但是由于该行是相对的,因此每个单元格都将引用同一行中的A列。 So B8's conditional format formula will be =$A8=1 因此B8的条件格式公式将为= $ A8 = 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM