dim i As Integer '''angle variable and row counter on summary page dim j As Integer '''column counter on summary page i=0 j=1 Do While i<57 '''Angles vary from 0 to 56 Sheets("Temp_Fit_Page").Select '''changing angle parameter Range("H4").Value = i '''solver section of code which is not included here j=1 Do While j<49 '''there are 48 output columns If 1 <= j <= 9 Then '''outputting peak positions Sheets("Temp_Fit_Page").Cells(j + 3, 11).Copy Sheets("PL_Summary").Cells(i + 2, j + 1).PasteSpecial End if If 10 <= j <= 18 Then '''outputting peak heights Sheets("Temp_Fit_Page").Cells(j - 6, 12).Copy Sheets("PL_Summary").Cells(i + 2, j + 1).PasteSpecial End If If 19 <= j <= 27 Then '''outputting peak linewidths Sheets("Temp_Fit_Page").Cells(j - 15, 13).Copy Sheets("PL_Summary").Cells(i + 2, j + 1).PasteSpecial End If If 28 <= j <= 36 Then '''outputting peak areas Sheets("Temp_Fit_Page").Cells(j - 24, 14).Copy Sheets("PL_Summary").Cells(i + 2, j + 1).PasteSpecial End If If 37 <= j <= 45 Then '''outputting peak offsets Sheets("Temp_Fit_Page").Cells(j - 33, 15).Copy Sheets("PL_Summary").Cells(i + 2, j + 1).PasteSpecial End If If 46 <= j <= 47 Then '''outputting background gradient and intercept Sheets("Temp_Fit_Page").Cells(15, j - 35).Copy Sheets("PL_Summary").Cells(i + 2, j + 1).PasteSpecial End If j=j+1 Loop i=i+1 Loop If 46 <= j <= 47 Then ''' outputting background gradient and intercept Cells(i + 2, j + 1).Value = j End If If 46 <= j <= 47 Then ''' outputting background gradient and intercept Cells(i + 2, j + 1).Value = Sheets("Temp_Fit_Page").Cells(15, j - 35).Value End If If 1 <= j <= 9 Then '''outputting peak positions k = j + 3 Sheets("Temp_Fit_Page").Select Cells(k, 11).Select Selection.Copy Sheets("PL_Summary").Select Cells(i + 2, j + 1).Select Selection.PasteSpecial End If