VBA 打开excel

Sub openExcelFile(ByVal filePath$)
Set xls = CreateObject("Excel.Application")
Set xlbook = xls.Workbooks.Open(filePath)
'xls.Visible = True
Set xlsheet = xlbook.Worksheets(1)
Application.ScreenUpdating = False
    With xlsheet
        MsgBox .[a2]
    End With
    
 Application.ScreenUpdating = True

xlbook.Close (True)
    xls.Quit
    
    Set xlsheet = Nothing
    Set xlbook = Nothing
    Set xls = Nothing
    
End Sub

 



Sub getSheetName()

For Each sht In ThisWorkbook.Sheets
    With sht
        If .Cells(2, 1).Value <> "" Then .Cells(2, 1).Interior.ColorIndex = 45
        
    
    End With

Next
End Sub
Sub getSheetName()
Dim arr
Dim c As Range
For Each sht In ThisWorkbook.Sheets
 If sht.Name = "Sheet2" Then
    With sht
     
        Set St = Worksheets("sheet1")
           'MsgBox St.[a1].End(2).Column
        For i = 1 To St.[a1].End(2).Column 'St.[a65536].End(3).Row
           If St.Cells(1, i).Value = .Name Then
           
            
                For ii = 1 To .[a65536].End(3).Row
                    'If .Cells(ii, 1).Value Then
                    
                    Set c = St.Range(St.Cells(1, i), St.Cells(St.Cells(65536, i).End(3).Row, i)).Find(.Cells(ii, 1), , , 1)
                    If Not c Is Nothing Then
                        MsgBox "a"
                    End If
                Next
                
                Exit For
           End If
            'If .Cells(2, 1).Value <> "" Then .Cells(2, 1).Interior.ColorIndex = 45
        
        Next
    End With
 End If
Next
End Sub

转载于:https://www.cnblogs.com/yuzhengdong/p/3315984.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值