田庭聿EXCEL基本功能,VBA巨集程式設計

 


畫圖VBA程式碼

'Dr Ian O'Connor, CPA. - located in Victoria, Australia.

'2021/11/29劉任昌指導我從 Option Explicit Const topleft As String = "C5" ' anchor cell Const diam As Integer = 180 ' points Dim Shp As Shape '宣告dim 變數Shp是圖形Shape global Sub xlfAddCircle1() Dim TLCleft As Double 'local variables區域變數 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 End Sub Sub 劉任昌超級臭屁() 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 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 刪除() For Each Shp In ActiveSheet.Shapes 'Shp 共用的物件宣告成全域變數 Shp.Delete Next End Sub
只顯示部分資訊

留言

這個網誌中的熱門文章

SVG

田庭聿time套件

田庭聿vs code期中考