許程程VBA雙迴圈Loop與JavaScript迴圈 VBA AddShape

VBA迴圈畫圖

VBA迴圈畫圖程式碼

  
Dim Shp As Shape '宣告變數Shp是 圖形 全域變數global 非區域變數local
Sub 許程程刪除()
   For Each Shp In ActiveSheet.Shapes
      Shp.Delete '刪除使用中試算表ActiveSheet的所有圖形Shapes
   Next
End Sub

' ===========================
Sub 許程程()
Dim Shp As Shape '宣告變數Shp是 圖形
Dim x As Double '宣告變數x是倍數經度實數Double
Dim y As Double '宣告變數y是倍數經度實數Double
Dim i As Integer '宣告變數i是整數Double
For i = 1 To 20 '寫迴圈
    x = 20 * i
    y = 20 * i
        
        Set Shp = ActiveSheet.Shapes.AddShape(msoShapeOval, x, y, 30, 60 )
        With Shp
                .Fill.Visible = msoFalse
                .Line.Weight = 10
                .Line.ForeColor.Brightness = 0.4
                .ThreeD.BevelTopType = msoBevelCircle
        End With
Next
With Cells(1, 1)
.Value = "許程程" '在儲存格1,1放入字串string
.Interior.Color = RGB(0, 0, 255) 'interior desing室內設計
With .Font
.Size = 24
.Bold = True
.Color = RGB(255, 255, 255)
End With
End With
End Sub

JavaScript雙迴圈

輸出

EXCEL VBA雙迴圈

Option Explicit    '必須宣告所有變數variables
Dim i, j As Integer '宣告dimension i, j 是整數integer

Public Sub 劉任昌()
  Cells(1, 1).Value = "劉任昌超級帥"
  Cells(1, 1).Font.Size = 20
  Cells(1, 1).Interior.Color = RGB(128, 0, 0)
  Cells(1, 1).Font.Color = RGB(255, 255, 255)
End Sub
Public Sub 劉任昌迴圈()
   For i = 2 To 10
      For j = 1 To 6
        Cells(i, j).Value = (2010 + i) & "年" & j & "月"
    Next
   Next
End Sub

RGB顏色控制

檔案前頭程式碼

留言

這個網誌中的熱門文章

許程程EXCEL樞紐分析weeekday

許程程,樞紐分析,上市公司簽證會計師事務所