Hi all,
New to the board and posting in general so apologies if I get anything wrong
It's probably easier if I explain from scratch.
I download a report each day in xml format, import this to excel then run vba code to split the data into batches of 26. I then move onto next report repeating the same process. The problem I have is I need to paste the code into excel each time I open a new XML file. Is there a way around this?
Any help appreciated. The code I use is the following:
Code
- Sub test()
- Dim iCalc As Long, i As Long
- iCalc = Application.Calculation
- With Application
- .Calculation = xlManual
- .ScreenUpdating = False
- .EnableEvents = False
- End With
- With ThisWorkbook.ActiveSheet
- For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Step 26
- Range(.Range("A1:H1").Address(0, 0) & "," & .Range(Cells(i, "A"), Cells(i, "H").Resize(30)).Address(0, 0)).Copy
- Workbooks.Add
- Range("A1").PasteSpecial xlPasteValues
- With ActiveWorkbook
- .SaveAs Filename:="C:\data\" & i & ".xlsx"
- .Close
- End With
- Next i
- End With
- With Application
- .Calculation = iCalc
- .ScreenUpdating = True
- .EnableEvents = True
- End With
- End Sub