I got tired of having to go in and open each shot track separately so I wrote a short macro that will copy/paste all the individual shots into their individual sheet within the main sheet. So the first sheet will have the usual shot data (average, max, min, etc), second sheet will be Shot 1, third will be shot 2, and so on. I’ve tested it to double digit shots, and it works fine. Should also work for 100+ shots, but would be pretty cumbersome at that point.
To use it:
Hope this helps someone else…
John
Edit.. changed "Range("a1:d150").Select" to "Range("a1:d350").Select" so it will copy all the data over.
Sub combine_it()
Dim zz As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False
num_pages = Cells(4, 2)
For n = 1 To num_pages
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Shot " & n
Next n
the_path = Application.ActiveWorkbook.Path
For m = 1 To num_pages
a = Len(m)
If a = 1 Then zz = "000" & m
If a = 2 Then zz = "00" & m
If a = 3 Then zz = "0" & m
If a = 4 Then zz = m
Dim y As Workbook
Set y = Workbooks.Open(the_path & "/trk/shot" & zz & " Track.csv")
Range("a1:d350").Select
Selection.Copy
y.Close True
Worksheets("Shot " & m).Activate
ActiveSheet.Cells(1, 1).Select
ActiveSheet.Paste
Next m
Application.DisplayAlerts = True
Application.ScreenUpdating = True
msgbox("Done")
End Sub
To use it:
- Copy from ‘Sub’ to ‘End Sub’ below.
- Open the report sheet (like “SR0003 Report), make sure you are on the sheet with the report data. Note: TRK folder has to be left as subfolder for this to work.
- Hit ALT+F11 (or Function+Alt+F11 if you don’t have dedicated function keys like on a laptop) to bring up the visual basic editor.
- On the menu bar, go to ‘Insert’ and hit ‘Module’.
- Paste what you copied into the module.
- You should see a green ‘play’ arrow in the toolbar, click that and it should Run. Or you can go to Run on the toolbar and hit ‘Run Sub’.
Hope this helps someone else…
John
Edit.. changed "Range("a1:d150").Select" to "Range("a1:d350").Select" so it will copy all the data over.
Sub combine_it()
Dim zz As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False
num_pages = Cells(4, 2)
For n = 1 To num_pages
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Shot " & n
Next n
the_path = Application.ActiveWorkbook.Path
For m = 1 To num_pages
a = Len(m)
If a = 1 Then zz = "000" & m
If a = 2 Then zz = "00" & m
If a = 3 Then zz = "0" & m
If a = 4 Then zz = m
Dim y As Workbook
Set y = Workbooks.Open(the_path & "/trk/shot" & zz & " Track.csv")
Range("a1:d350").Select
Selection.Copy
y.Close True
Worksheets("Shot " & m).Activate
ActiveSheet.Cells(1, 1).Select
ActiveSheet.Paste
Next m
Application.DisplayAlerts = True
Application.ScreenUpdating = True
msgbox("Done")
End Sub
Last edited: