|
大神帮助改一下代码,能否将这段代码改成根据A列有内容时,才执行隔行填充内容,A列无内容就停止。
下面这段代码选择区域是A6:G2637,如果同一工作薄的其他几个工作表的区域是A6:G列任意行数,代码就会对A6:G2637区域执行隔行填充,有的工作表可能区域还没到G2637,有的已经超出了。如何写代码呢?
- Sub 奇偶()
- '
- ' 奇偶 宏
- '
- ' 快捷键: Ctrl+Shift+Z
- '
- Range("A6:G2637").Select
- Selection.FormatConditions.add Type:=xlExpression, Formula1:= _
- "=MOD(ROW(),2)=0"
- Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
- With Selection.FormatConditions(1).Interior
- .PatternColorIndex = xlAutomatic
- .ThemeColor = xlThemeColorDark1
- .TintAndShade = -0.14996795556505
- End With
- Selection.FormatConditions(1).StopIfTrue = False
- End Sub
复制代码
|
|