|
本帖最后由 hwc2ycy 于 2013-3-6 08:57 编辑
- Sub 设置背景色()
- Dim rg As Range
- Dim blStart As Boolean
- Dim lRow As Long, lCol As Long
- For lRow = 1 To 11
- For lCol = 24 To 70
- Select Case blStart
- Case True:
- If Len(Cells(lRow, lCol)) > 0 Then
- If rg Is Nothing Then
- Set rg = Cells(lRow, lCol)
- Else
- Set rg = Union(rg, Cells(lRow, lCol))
- End If
- If Len(Cells(lRow, lCol + 1)) = 0 Then
- blStart = False
- End If
- End If
- Case False
- If Len(Cells(lRow, lCol)) > 0 And Len(Cells(lRow, lCol + 1)) > 0 Then
- If rg Is Nothing Then
- Set rg = Cells(lRow, lCol)
- Else
- Set rg = Union(rg, Cells(lRow, lCol))
- End If
- 'Cells(lRow, lCol).Interior.ColorIndex = 3
- blStart = True
- End If
- End Select
- Next
-
- If blStart Then
- If rg Is Nothing Then
- Set rg = Cells(lRow, lCol)
- Else
- Set rg = Union(rg, Cells(lRow, lCol))
- End If
- End If
- blStart = False
- Next
- rg.Interior.ColorIndex = 6
- End Sub
复制代码 |
|