counter = 1
' selecting first paste reference
Range("B2").Select
' define offset var
Dim offsetvar As Variant
offsetvar = confignumb + 1
' confignumb is the number of days specified by the user. So if there are 2 days selected, the offsetvar will begin at a value of 3. For example on loop 1, it will paste into col B, E, H, K and N. There's an extra column in between the 5 paste destinations, that is why I add 1
' day loops
Do
' Message prompt to pick the next DAY
MsgBox ("Please select day " & counter & " of the week")
' Variable declaration
Dim Day1 As String
' Assigning filename to variable
Day1 = Application.GetOpenFilename("Excel Files (*.xls),*.xls", , , , False)
' Opening the file
Workbooks.OpenText Filename:=Day1
' Set a new variable for this workbook to reference when opening
Dim day1WB As String
day1WB = ActiveWorkbook.Name
'Select main worksheet
Sheets(1).Select
' IM CREATING COLUMNS IN THE SELECTED FILE FOR COPYING
Range("Z1").Value = "AvgTC12"
Range("Z2").Formula = "=median(E2:F2)"
Range("Z2").Select
Selection.AutoFill Destination:=Range("Z2:Z1442")
Range("AA1").Value = "AvgTC34"
Range("AA2").Formula = "=median(G2:H2)"
Range("AA2").Select
Selection.AutoFill Destination:=Range("AA2:AA1442")
Range("AB1").Value = "AvgTC56"
Range("AB2").Formula = "=median(I2:J2)"
Range("AB2").Select
Selection.AutoFill Destination:=Range("AB2:AB1442")
' Copying the first column
Range("Z2:Z1442").Copy
'Activating this workbook
Application.Workbooks("Book1").Activate
' Pasting first column into main book
ActiveCell.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Activating the specified day workbook to get average columns
Windows(day1WB).Activate
' Copying the second column
Range("AA2:AA1442").Copy
'Activating this workbook
Application.Workbooks("Book1").Activate
' Pasting second column into main book
ActiveCell.Offset(0, offsetvar).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Activating the specified day workbook to get average columns
Windows(day1WB).Activate
' Copying the third column
Range("AB2:AB1442").Copy
'Activating this workbook
Application.Workbooks("Book1").Activate
' Pasting third column into main book
ActiveCell.Offset(0, offsetvar * 2).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Activating the specified day workbook to get TC7 indoor for this day
Windows(day1WB).Activate
' Copying the fourth column
Range("K2:K1442").Copy
'Activating this workbook
Application.Workbooks("Book1").Activate
' Pasting fourth column into main book
ActiveCell.Offset(0, offsetvar * 3).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Activating the specified day workbook to get HFD1 indoor for this day
Windows(day1WB).Activate
' Copying the 5th column
Range("P2:P1442").Copy
'Activating this workbook
Application.Workbooks("Book1").Activate
' Pasting 5th column into main book
ActiveCell.Offset(0, offsetvar * 4).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'redefine offsetvar
offsetvar = confignumb + 1
' Closing day workbook
Windows(day1WB).Activate
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
'Select next start location, so from b2 we wil now start at c2
ActiveCell.Offset(0, 1).Select
'counter addition
counter = counter + 1
Loop While counter < (confignumb + 1)