2018年11月12日月曜日

VBA20181112

Sub sss()

Dim rng As Range

Set rng = Range("B1")
'rng.Select


Dim i As Integer
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
i = 20
Set rng = Union(rng, Range("A" & i - 1 & ":C" & i + 1))

rng.BorderAround LineStyle:=xlContinuous
rng.Interior.Color = &HC0C0C0

Set rng = Nothing

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Set rng = Range("B1")
Set rng = Union(rng, Range("D" & i - 1 & ":G" & i + 1))

rng.BorderAround LineStyle:=xlContinuous
rng.Interior.Color = vbWhite

Set rng = Nothing


'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
i = 23
Set rng = Range("B1")
Set rng = Union(rng, Range("A" & i - 1 & ":C" & i + 1))

rng.BorderAround LineStyle:=xlContinuous
rng.Interior.Color = &HC0C0C0

Set rng = Nothing

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Set rng = Range("B1")
Set rng = Union(rng, Range("D" & i - 1 & ":G" & i + 1))

rng.BorderAround LineStyle:=xlContinuous
rng.Interior.Color = vbWhite

Set rng = Nothing


'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
i = 29
Set rng = Range("A" & i - 1 & ":C" & i + 1)

rng.BorderAround LineStyle:=xlContinuous
rng.Interior.Color = &HC0C0C0

Set rng = Nothing

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Set rng = Range("D" & i - 1 & ":G" & i + 1)

rng.BorderAround LineStyle:=xlContinuous
rng.Interior.Color = vbWhite

Set rng = Nothing


'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
i = 32
Set rng = Range("A" & i - 1 & ":C" & i + 1)

With rng
.BorderAround LineStyle:=xlContinuous
.Borders(xlEdgeTop).LineStyle = xlLineStyleNone
.Interior.Color = &HC0C0C0
End With

Set rng = Nothing

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Set rng = Range("D" & i - 1 & ":G" & i + 1)

With rng
.BorderAround LineStyle:=xlContinuous
.Borders(xlEdgeTop).LineStyle = xlDash
.Interior.Color = vbWhite
End With

Set rng = Nothing


'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Set rng = Range("B1")
'rng.Select

Set rng = Union(rng, Range("E2:F3"))
rng.Select
rng.BorderAround LineStyle:=xlContinuous

rng.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone
'rng.Borders.LineStyle = xlLineStyleNone

rng.Borders(xlEdgeBottom).LineStyle = xlDash

'背景色
rng.Interior.Color = vbRed





'Application.Union.Borders.



End Sub

Sub rrr()

Dim rng As Range

Set rng = Cells(1, 1)
'rng.Select



Set rng = Union(rng, Cells(3, 4))
rng.Select

'rng.Borders.Color = vbRed
'rng.Borders.LineStyle
rng.Borders(xlEdgeTop).LineStyle = xlContinuous
rng.Borders(xlEdgeLeft).LineStyle = xlContinuous
rng.Borders(xlEdgeRight).LineStyle = xlContinuous
rng.Borders(xlEdgeBottom).LineStyle = xlContinuous

Set rng = Nothing


Set rng = Cells(7, 7)
'rng.Select

Set rng = Union(rng, Cells(10, 12))
rng.Select
rng.BorderAround LineStyle:=xlContinuous

rng.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone
'rng.Borders.LineStyle = xlLineStyleNone

rng.Borders(xlEdgeBottom).LineStyle = xlDash

'背景色
rng.Interior.Color = vbBlue





'Application.Union.Borders.

End Sub

Sub qqq()

Dim rng As Range

Set rng = Range("B1")
'rng.Select



Set rng = Union(rng, Range("A2:C3"))
rng.Select

'rng.Borders.Color = vbRed
'rng.Borders.LineStyle
rng.Borders(xlEdgeTop).LineStyle = xlContinuous
rng.Borders(xlEdgeLeft).LineStyle = xlContinuous
rng.Borders(xlEdgeRight).LineStyle = xlContinuous
rng.Borders(xlEdgeBottom).LineStyle = xlContinuous

Set rng = Nothing


Set rng = Range("B1")
'rng.Select

Set rng = Union(rng, Range("E2:F3"))
rng.Select
rng.BorderAround LineStyle:=xlContinuous

rng.Borders(xlEdgeBottom).LineStyle = xlLineStyleNone
'rng.Borders.LineStyle = xlLineStyleNone

rng.Borders(xlEdgeBottom).LineStyle = xlDash

'背景色
rng.Interior.Color = vbRed





'Application.Union.Borders.

End Sub