宏参数使用案例

 

 

案例一

Public Sub Test2(ByRef table As String)

      Sheets(table).Select    

   Columns("H:H").Select    

End Sub

'选中表 sheet1 H列

Sub cc()

    Test2 ("sheet1")

End Sub

案例二 名字带有参数

Sub m1(vargr As String, time As Integer)

Windows("var.xls").Activate
Sheets(vargr & "_m" & time & "2018").Select
Range("A1").Select
End Sub

Sub cc2(j As Integer)

Windows("分析.xlsx").Activate
Sheets("m" & j).Select

For i = 1 To 9

Call m1("group_org_" & i, j)
Next
For i = 1 To 9

Call m1("group_evt_" & i, j)

Next

End Sub

 

Sub cc4()

Call cc2(1)
Call cc2(3)


End Sub

posted on 2018-03-22 18:08  bx_yang  阅读(130)  评论(0编辑  收藏  举报