求助VBA
excel单元格内数字连线,VAB代码如何编写?如图:1、如何将单元格B2到J15区域内数字自动连线,B2到J15区域内数字由公式生成;2、并且使有数字的单元格填充颜色。
Private Sub Worksheet_SelectionChange(ByVal Target As Range) For Each c In Shapes c.Delete Next Set myDocument = Worksheets(1) For i = 2 To 15 For j = 2 To 10 If Cells(i, j) <> "" Then m = Cells(i, j).Left + Cells(i, j).Width / 2 n = Cells(i, j).Top + Cells(i, j).Height / 2 If x <> "" And y <> "" Then With myDocument.Shapes.AddLine(x, y, m, n).Line .ForeColor.RGB = RGB(255, 0, 0) End With End If x = m y = n End If Next Next End Subtest.zip (8.95 KB)