VBA入门

VBA入门之一

Private Sub CommandButton1_Click() //按钮事件

etxt = "Hello world!!!"

MsgBox etxt, 64, "宣告"

End SubPrivate Sub CommandButton2_Click()

MsgBox "你点击的单元格是: " & ActiveCell.Address & Chr(13) & "该单元格的值等于: " & ActiveCell.Value, 64, "神算子"

End Sub 

     

  VBA入门之二

 Sub Macro1()   //自动录制宏

' Macro1 Macro

'

'

    With ActiveWindow   //With语句 集中设置

        .DisplayHorizontalScrollBar = False

        .DisplayVerticalScrollBar = False

    End With

End Sub

Function ShtExist(ByVal ShtName As String) As Boolean  //判断指定的工作表是否存在

          On Error Resume Next                    //如果错误.跳出

          Dim Sht     As Worksheet

          Set Sht = Sheets(ShtName)

          If Not Sht Is Nothing Then ShtExist = True    //Nothing  : 一个空的对象引用.

  End Function

  Sub test()

          MsgBox ShtExist("sheet31")

  ---------------------------------------------------------------------------------------------|       

          Dim int1 As Worksheet              //测试代码

          Set int1 = Sheet1

    '      'Set int1 = Nothing       

    '      If Not int1 Is Nothing Then

    '      MsgBox int1.Name

    '      End If

             

  End Sub

   

   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值