Я пытаюсь активировать рабочую книгу с частичным именем.
Рабочая книга всегда называется "Task_State_ (Pivot) _xxxxxx", x - это случайные цифры, и эти цифры и изменяются.
Мой код:
Sub changingWorkbooks()
Dim wb As Workbook
Dim excelfile As String
'deletes the table (have to eventually put that at the beginning of my macro)
Windows("macro").Activate
Sheets(1).Select
Rows("3:3").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
For Each wb In Application.Workbooks
If Left(wb.Name, 10) = "Task_State" Then
excelfile = wb.Name
End If
Next wb
'going from horasphere data status+date, making it readable by
' converting it with the comma and pasting it into your masterfile table.
'have to find a way to have the macro find the file without a name
' as the name will always change.
Workbooks(excelfile).Activate
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1 _
), Array(14, 1), Array(15, 1), Array(16, 1)), TrailingMinusNumbers:=True
'this top part is to make the data readable by going into Data - Text to columns - etc
Я получаю ошибку времени выполнения: несоответствие типов
Моя ошибка возникает здесь: Workbooks(excelfile).Activate