엑셀 팁 : n번재 행 마다 녹책 칠하기~
Sub 두번째행마다녹색()
'
' 조건부 서식으로 선택 범위에서 n번째 행 마다 녹색으로 칠하기
'
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW(),2)=0" '선택범위에서 두번째 행부터 시작하여 둘째 행 단위로
'"=MOD(ROW(),2)=1" '선택범위에서 첫번째 행부터 시작하여 둘째 행 단위로
'"=MOD(ROW(),3)=1" '선택범위에서 세번째 행부터 시작하여 세번째 행 단위로
'"=MOD(ROW(),4)=0" '선택범위에서 네번째 행부터 시작하여 네번째 행 단위로
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599963377788629
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Sub ColorBandAlternateRows()
'
'선택 범위에서 2행 마다 녹색 칠하기..
'
Dim R As range, Ar As range, B As Boolean, i As Long, j As Long
Application.ScreenUpdating = False
Selection.Interior.Color = xlNone
On Error Resume Next
Set R = Selection.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If R Is Nothing Then Exit Sub
For j = 1 To R.Areas.Count
For i = 2 To R.Areas(j).Rows.Count
If Not B Then
R.Areas(j).Rows(i).Interior.Color = RGB(226, 239, 218)
B = True
Else
B = False
End If
Next i
Next j
Application.ScreenUpdating = True
End Sub
댓글 없음:
댓글 쓰기