|
楼主 |
发表于 2019-11-1 13:23
|
显示全部楼层
随行列宽高变化的代码
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim JGD As Shape, lc!, hh!, Col
If Sheet1.ToggleButton1.Caption = "聚光灯-已开" Then
n = Target.Row: Col = Target.Column: lc = Target.Width: hg = Target.Height
nn = Application.Max(n - 100, 1)
hs = Application.Max(Col - 100, 1)
On Error Resume Next
ActiveSheet.Shapes("聚光灯-已开").Delete
ActiveSheet.Shapes("聚光灯-已开").Delete
' For Each JGD In ActiveSheet.Shapes
' If JGD.Name = "聚光灯-已开" Then JGD.Delete '删除特定名称的图形
'Next
With ActiveSheet.Shapes.AddShape(msoShapeRectangle, Cells(nn, Col).Left, Cells(nn, Col).Top, lc, hg * 200)
.Line.Visible = msoFalse '设置为无轮廓
.Fill.Visible = msoTrue '设置填充(fill)颜色,如果=msofalse,则为无颜色填充
.Fill.ForeColor.RGB = RGB(247, 17, 238) '设置颜色
.Fill.Transparency = 0.6 '设置透明度,数字愈大透明度越高
.Name = "聚光灯-已开"
End With
With ActiveSheet.Shapes.AddShape(msoShapeRectangle, Cells(n, hs).Left, Cells(n, 1).Top, lc * 200, hg) 'hh)
.Line.Visible = msoFalse '设置为无轮廓
.Fill.Visible = msoTrue '设置填充(fill)颜色,如果=msofalse,则为无颜色填充
.Fill.ForeColor.RGB = RGB(247, 17, 238) '设置颜色
.Fill.Transparency = 0.6 '设置透明度,数字愈大透明度越高
.Name = "聚光灯-已开"
End With
End If
End Sub
|
评分
-
2
查看全部评分
-
|