EXCEL VBA 雙迴圈 Java Script 雙迴圈
VBA迴圈畫圖
VBA迴圈畫圖程式碼
'https://excelatfinance.com/xlf19/xlf-qg-add-blue-circle.php
Option Explicit
Const topleft As String = "C5" ' anchor cell
Const diam As Integer = 100 ' 宣告常數constant diam 100
Dim Shp As Shape
' ===========================
Sub 金諭慧()
Dim TLCleft As Double
Dim TLCtop As Double
Dim i As Integer '宣告整數integer i
For i = 1 To 20 'write a loop單引號註解
TLCleft = 20 * i '距離左邊left
TLCtop = 20 * i '距離上面top
'使用中的試算表active sheet.AddShape(type, left, top, height)
Set Shp = ActiveSheet.Shapes.AddShape(msoShapeOval, TLCleft, TLCtop, diam, diam)
With Shp
.Fill.Visible = msoFalse
.Line.Weight = 10
.Line.ForeColor.Brightness = 0.4
.ThreeD.BevelTopType = msoBevelCircle
End With
Next
With Cells(1, 1)
.Value = "金諭慧"
.Interior.Color = RGB(0, 0, 225)
.Columns.AutoFit
With .Font
.Size = 30
.Color = RGB(255, 255, 255)
End With
End With
End Sub
Sub 金諭慧刪除()
For Each Shp In ActiveSheet.Shapes 'Shp 共用的物件宣告成全域變數
Shp.Delete 'programming .method delete .property, font color
Next
End Sub
輸出
Public Sub 金諭慧()
Cells(1, 1) = "金諭慧"
Cells(1, 1).Font.Color = RGB(0, 0, 255)
Cells(1, 1).Font.Size = 20
For i = 2 To 15
For j = 1 To 4
Cells(i, j) = (2010 + i) & "年" & j & "月"
Next
Next
End Sub
下次上課,要來,提醒我協助你找出問題。
回覆刪除https://www.facebook.com/robertjcliu/posts/5093882470622940
回覆刪除