注册 登录
编程论坛 Excel/VBA论坛

求助VBA

love0712 发布于 2018-11-26 20:24, 1902 次点击
excel单元格内数字连线,VAB代码如何编写?
如图:1、如何将单元格B2到J15区域内数字自动连线,B2到J15区域内数字由公式生成;2、并且使有数字的单元格填充颜色。

只有本站会员才能查看附件,请 登录

只有本站会员才能查看附件,请 登录
4 回复
#2
wengjl2018-12-14 08:40
这游戏意义何在?
#3
icecool2018-12-14 08:47
彩票走势分析
#4
icecool2018-12-14 09:52
程序代码:

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 Sub
只有本站会员才能查看附件,请 登录

#5
icecool2018-12-14 09:56
忘了,填充颜色再加一句
Cells(i, j).Interior.Color = 65535
1