I am creating an excel macro which automatically enters the stats from daily_stats.xlsx into cells D10:D33 and cells E10:E33 from a file called statistics.txt.
These stats are generated everyday and the target cells for tomorrow are to the right of the current cells.
So todays stats go into:
D10:D33 and E10:E33
tomorrows will go into:
F10:F33 and G10:G33
the day after tomorrow will go into:
H10:H33 and I10:I33...
and so on..
How can I alter the syntax below so that whenever it picks up the text file "stats.txt" it will automatically enter it to the 2 columns to the right if the target cells have already been generated?
Thanks in advance
My syntax is as follows:
Sub Macro1()
Workbooks.OpenText Filename:= _
"C:\Users\username\Desktop\stats.txt" _
, Origin:=xlMSDOS, StartRow:=2, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False, _
Comma:=False, Space:=True, Other:=False, FieldInfo:=Array(Array(1, 9), _
Array(2, 1), Array(3, 1), Array(4, 9), Array(5, 9)), TrailingMinusNumbers:=True
Range("A1:A24").Select
Selection.Copy
Windows("daily_stats.xlsx").Activate
Range("D10").Select
ActiveSheet.Paste
Windows("stats.txt").Activate
Range("B1:B24").Select
Application.CutCopyMode = False
Selection.Copy
Windows("daily_stats.xlsx").Activate
Range("E10").Select
ActiveSheet.Paste
Windows("stats.txt").Activate
ActiveWindow.Close
Range("D10").Select
End Sub