从文本框中取出文本并将其放入新工作簿中

时间:2015-04-10 18:16:28

标签: excel vba

我需要获取一个名为data6的文本框的文本(引用(=Invoice!$E$13))(我需要将数千个文件从中提取出来)并输入一个名为clients 2的新工作簿,无论是我尝试的东西似乎无法调出文本框并从中获取信息。

Sub clients()
  Dim directory As String
  Dim fileName As String
  Dim clients As String
  Dim sheet As Worksheet
  Dim i As Integer
  Dim j As Integer
  directory = "C:\Users\Owner\Desktop\TEST\"
  fileName = Dir(directory & "*.xl??")
  clients = Dir(directory & "clients2.xlsx")
  Do While fileName <> ""
    i = i + 1
    j = 2
    Application.ScreenUpdating = False
    With Workbooks.Open(directory & fileName)
      For Each sheet In Workbooks(fileName).Worksheets
        ThisWorkbook.Sheets(1).Cells(i, j).value = sheet.Name
        ThisWorkbook.Sheets(1).Cells(i, 1).value = fileName
        j = j + 1
      Next sheet
      .Close 'close without saving
    End With
    fileName = Dir()
  Loop
  Application.ScreenUpdating = True
End Sub 

0 个答案:

没有答案