#使い方とかがかっこ悪いので時間はがある時に見直す予定。
Sub group_out_line()
t = Selection.Address
t = Replace(t, "$", "")
startcell = InStr(t, ":")
s = Left(t, (startcell - 1))
s = "$" & s
e = Mid(t, (startcell + 1), 10000)
n = ActiveCell.Offset(-1, 0).Address
n = Replace(n, "$", "")
n = "$" & n
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=" & n & "<>" & s
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
Selection.FormatConditions(1).StopIfTrue = False
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=AND(" & s & "=" & n & "," & s & "<>" & """"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlDot
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=" & s & "="""""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlContinuous
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlLineStyleNone
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlLineStyleNone
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub