江宥蓉EXCEL與JavaScript迴圈pre
畫圖
畫圖
'拷貝自https://excelatfinance.com/xlf19/xlf-...
'Dr Ian O'Connor, CPA. - located in Victoria, Australia.
Option Explicit
Const topleft As String = "C5" ' anchor cell
Const diam As Integer = 180 ' points
Sub xlfAddCircle1()
Dim Shp As Shape
Dim TLCleft As Double
Dim TLCtop As Double
TLCleft = Range(topleft).Left
TLCtop = Range(topleft).Top
Set Shp = ActiveSheet.Shapes.AddShape(Type:=msoShapeOval, _
Left:=TLCleft, Top:=TLCtop, _
Width:=diam, Height:=diam)
With Shp
.Fill.Visible = msoFalse
.Line.Weight = 10
.Line.ForeColor.Brightness = 0.4
.ThreeD.BevelTopType = msoBevelCircle
End With
With Cells(1, 1) 'with 固定前面的物件end with
.Value = "江宥蓉"
.Interior.Color = RGB(0, 0, 255)
With .Font
.Size = 16
.Bold = True
.Color = RGB(255, 255, 255)
End With
End With
End Sub
Sub 江宥蓉()
Dim Shp As Shape '宣告dim 變數shp是圖形shape
Dim x As Double '宣告 x 是倍精度double
Dim y As Double '宣告 y 是倍精度double
Dim i As Integer '宣告整數i
For i = 1 To 20
x = 20
y = 20 * i
Set Shp = ActiveSheet.Shapes.AddShape(Type:=msoShapeOval, Left:=x, Top:=y, Width:=diam, Height:=diam)
With Shp
.Fill.Visible = msoFalse
.Line.Weight = 10
.Line.ForeColor.Brightness = 0.4
.ThreeD.BevelTopType = msoBevelCircle
End With
Next
End Sub
Sub 刪除()
For Each Shp In ActiveSheet.Shapes 'Shp 共用的物件宣告成全域變數
Shp.Delete
Next
End Sub
輸出
EXCEL學習
'變數variables應該要宣告 pre=preserve保留
Option Explicit '要求所有變數必須宣告才能使用
Dim i, j As Integer
'Dimension 宣告指令
Public Sub 江宥蓉()
Cells(1, 6).Value = 江宥蓉
Cells(1, 6).Font.Color = RGB(0, 0, 256)
Cells(1, 6).Font.Bold = True
End Sub
Public Sub 豬八戒()
For i = 1 To 7
For j = 1 To 5
Cells(i, j).Value = i * j
Next
Next
End Sub
https://www.facebook.com/robertjcliu/posts/4964695996874922
回覆刪除