如何令VBA因應輸入按日期COPY到相對應WORKSHEET

GERRARD


我已經完成了因應輸入按日期打開相對應檔案,
但如何令VBA因應輸入按日期COPY到相對應WORKSHEET?
例如 dd 是 01102019, 會將檔案 COPY 到 WORKSHEET "01", 求救

Sub Macro1()
'
' Macro1 Macro
'

' Dim Msg, fileValue
Msg = "Enter the data with the following format ddmmyyyy"
fileValue = InputBox(Msg)
If IsNumeric(fileValue) And Len(fileValue) = 8 Then

Workbooks.Open (ThisWorkbook.Path & "\" & fileValue & ".txt")
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, 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)), TrailingMinusNumbers:=True
Cells.Select
Selection.Copy

Windows("EF Guest Count.xlsm").Activate
Sheets("01").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows(fileValue & ".txt").Activate
ActiveWorkbook.Close SaveChanges:=True

End If
End Sub

roar
試看看把 Windows("EF Guest Count.xlsm").Activate 換成以下可不可行。
Workbooks.Open("EF Guest Count.xlsm")
GERRARD
可能我問題唔清楚, 其實我會輸入日期 DDMMYYYY, WORKSHEET 亦有 01 - 31, 我如何令 EXCEL 知道 FILE 日期而自動 COPY 到相對 WORKSHEET, 例如 FILE 日期為 08102019, COPY 到 WORKSHEET 08?
回到頂部