您的位置:首页 > 编程语言 > VB

Excel Vba

2008-12-30 18:23 411 查看
 Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Err
Dim wb As Workbook
Dim StrCell, StrCell2, StrCell3, StrFlod, StrWorkbook As String
 
    With Application
      .ScreenUpdating = False
      .EnableEvents = False
      
   
      StrCell = Cells(1, 1).Value
      StrCell2 = Cells(2, 1).Value
      StrCell3 = Cells(3, 1).Value
      StrFlod = "D:/TEST"
      Cells(1, 2) = StrFlod
   
      StrWorkbook = "/" & StrCell & "-" & StrCell2 & "-" & StrCell3 & ".xls"
      Set wb = Workbooks.Open(StrFlod & StrWorkbook, True, True)
                  
      Cells(2, 2) = StrFlod & StrWorkbook
      Cells(3, 2) = wb.Worksheets(StrCell & "-" & StrCell2 & "-" & StrCell3).Cells(1, 1)
        
      Cells(4, 2) = Application.WorksheetFunction.VLookup(Cells(5, 1), Workbooks(StrFlod & StrWorkbook).Worksheets(StrCell & " - " & StrCell2 & " - " & StrCell3).Range("A1:B46"), 2, False)
         wb.Close False
         Set wb = Nothing
   
          .EnableEvents = True
     .ScreenUpdating = True
    End With
    Exit Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  vba excel application string