|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub Main()
- With Sheet1.Range("a3:c5")
- ar = .Value
- cLine .Cells(1), .Cells(7), ar(1, 1) > 0 And ar(2, 1) > 0 And ar(3, 1) > 0
- cLine .Cells(1), .Cells(9), ar(1, 1) > 0 And ar(2, 2) > 0 And ar(3, 3) > 0
- cLine .Cells(1), .Cells(3), ar(1, 1) > 0 And ar(1, 2) > 0 And ar(1, 3) > 0
- cLine .Cells(2), .Cells(8), ar(1, 2) > 0 And ar(2, 2) > 0 And ar(3, 2) > 0
- cLine .Cells(2), .Cells(4), ar(1, 2) > 0 And ar(2, 1) > 0
- cLine .Cells(2), .Cells(6), ar(1, 2) > 0 And ar(2, 3) > 0
- cLine .Cells(3), .Cells(7), ar(1, 3) > 0 And ar(2, 2) > 0 And ar(3, 1) > 0
- cLine .Cells(3), .Cells(9), ar(1, 3) > 0 And ar(2, 3) > 0 And ar(3, 3) > 0
- cLine .Cells(4), .Cells(6), ar(2, 1) > 0 And ar(2, 2) > 0 And ar(2, 3) > 0
- cLine .Cells(4), .Cells(8), ar(2, 1) > 0 And ar(3, 2) > 0
- cLine .Cells(6), .Cells(8), ar(2, 3) > 0 And ar(3, 2) > 0
- cLine .Cells(7), .Cells(9), ar(3, 1) > 0 And ar(3, 2) > 0 And ar(3, 3) > 0
- End With
- End Sub
- Private Function cLine(rng1 As Range, rng2 As Range, flag0 As Boolean)
- On Error Resume Next
- Dim lNm As String
- lNm = rng1.Address(0, 0) & "_" & rng2.Address(0, 0)
- Sheet1.Shapes(lNm).Delete
- Err.Clear
- If flag0 Then
- With Sheet1.Shapes.AddLine(rng1.Left + rng1.Width / 2, rng1.Top + rng1.Height / 2, _
- rng2.Left + rng2.Width / 2, rng2.Top + rng2.Height / 2)
- .Line.ForeColor.RGB = vbRed
- .Name = lNm
- End With
- End If
- End Function
复制代码
|
|