使用Excel中的Userform的流程图

时间:2018-04-11 15:59:18

标签: excel userform flowchart

我有一个Userform来创建流程图。如何使用commandbutton1重复插入形状并在等距位置移动框,即。如何重复if statements直到commandbutton1被按下?

此代码仅选择第一个形状,我想在点击cmdbutton1时插入形状。

Sub CommandButton1_Click()   
    If OptionButton1 = True Then    
        Sheets("Sheet2").Select
        ActiveSheet.Shapes.AddShape(1, 68, 99, 136, 57).Select     
        Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = Me.TextBox1.Value    
        Selection.ShapeRange.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
        UserForm1.TextBox1.Value = ""   
    ElseIf OptionButton2 = True Then   
        Sheets("Sheet2").Select
        ActiveSheet.Shapes.AddShape(9, 68, 99, 136, 57).Select
        Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = Me.TextBox1.Value
        Selection.ShapeRange.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
        UserForm1.TextBox1.Value = ""   
    ElseIf OptionButton3 = True Then   
        Sheets("Sheet2").Select
        ActiveSheet.Shapes.AddShape(2, 68, 99, 136, 57).Select
        Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = Me.TextBox1.Value
        Selection.ShapeRange.TextFrame2.AutoSize = msoAutoSizeShapeToFitText
        UserForm1.TextBox1.Value = ""
    End If

    ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 135.75, 120, 135.5, 165).Select
    Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadTriangle
End Sub

0 个答案:

没有答案