Hi Dalek Dave
Thank you for answering and yes I should included some code...
This is the code: So as mentioned when its finished running through filling in all the columns and rows I want to then leave 3 columns blank and start filling 3 columns from row 2 down, this is to auto fill the equations in the cells. i tried adding it to the inner loop but it bombs out when it hits the end of the recordset so i need to know how to add the relevant code to start writting in the cells again from where I decide the active cell should be.
<!--#include virtual="/Connections/Asda.asp" -->
<%
Response.ContentType = "application/vnd.ms-excel"
Dim Confirm_data
Dim Confirm_data_cmd
Dim Confirm_data_numRows
Set Confirm_data_cmd = Server.CreateObject ("ADODB.Command")
Confirm_data_cmd.ActiveConnection = MM_Asda_STRING
Confirm_data_cmd.CommandText = "SELECT dbo.Tbl_Down_Fleet.Inp_ID,Site_Name,dbo.Tbl_Down_Fleet.Day_No,dbo.Tbl_Down_Fleet.Inp_Date, dbo.Tbl_Down_Fleet.Reach_Total, dbo.Tbl_Down_Fleet.LLOP_Total, dbo.Tbl_Down_Fleet.PPT_Total, dbo.Tbl_Down_Fleet.CB_Total, dbo.Tbl_Down_Fleet.ECB_Total, dbo.Tbl_Down_Fleet.BDU_Total, dbo.Tbl_Down_Fleet.PPPT_Total, dbo.Tbl_Down_Fleet.PPPTBC_Total, dbo.Tbl_Down_Fleet.Dollop_Total, dbo.Tbl_Down_Fleet.Kombi_Total, dbo.Tbl_Down_Fleet.Beast_Total,dbo.Tbl_Down_Fleet.Day_No,dbo.Tbl_Down_Fleet.Inp_Date, dbo.Tbl_Down_Fleet.Reach, dbo.Tbl_Down_Fleet.LLOP, dbo.Tbl_Down_Fleet.PPT, dbo.Tbl_Down_Fleet.CB, dbo.Tbl_Down_Fleet.ECB, dbo.Tbl_Down_Fleet.BDU, dbo.Tbl_Down_Fleet.PPPT, dbo.Tbl_Down_Fleet.PPPTBC, dbo.Tbl_Down_Fleet.Dollop, dbo.Tbl_Down_Fleet.Kombi, dbo.Tbl_Down_Fleet.Beast FROM dbo.Tbl_Down_Fleet, dbo.Tbl_Primary_Fleet WHERE Fleet_ID =Priflt_ID ORDER BY Site_Name ASC"
Confirm_data_cmd.Prepared = true
Confirm_data_cmd.Parameters.Append Confirm_data_cmd.CreateParameter("param1", 5, 1, -1, Confirm_data__MMColParam) ' adDouble
Set RS = Confirm_data_cmd.Execute
%>
<TABLE BORDER=1>
<TR>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop through Fields Names and print out the Field Names
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
j = 2 'row counter
For i = 0 to 15 - 1
%>
<TD><B><% = RS(i).Name %></B></TD>
<% Next %>
<TD><B><% Response.Write("Total Fleet")%></B></TD>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop again through remaining Headers
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
For i = 15 to RS.Fields.Count -1
%>
<TD><B><% = RS(i).Name %></B></TD>
<% Next %>
<TD><B><% Response.Write("Sum")%></B></TD>
<TD><B><% Response.Write("Reach")%></B></TD>
<TD><B><% Response.Write("LLOP")%></B></TD>
<TD><B><% Response.Write("PPT")%></B></TD>
<TD><B><% Response.Write("CB")%></B></TD>
<TD><B><% Response.Write("ECB")%></B></TD>
<TD><B><% Response.Write("BDU")%></B></TD>
<TD><B><% Response.Write("PPPT")%></B></TD>
<TD><B><% Response.Write("PPPTBC")%></B></TD>
<TD><B><% Response.Write("Dollop")%></B></TD>
<TD><B><% Response.Write("Kombi")%></B></TD>
<TD><B><% Response.Write("Beast")%></B></TD>
<TD><B><% Response.Write("dfleet")%></B></TD>
</TR>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop through rows, create first set of Fleet Totals
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Do While Not RS.EOF
%>
<TR>
<% For i = 0 to 15 - 1 %>
<TD VALIGN=TOP><% = RS(i) %></TD>
<% Next %>
<TD VALIGN=TOP><% Response.Write("=SUM(E"&(j)&":O"&(j)&")") %></TD>
<%
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Loop through rows, create second set of Fleet Down Totals
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%>
<% For i = 15 to RS.Fields.Count -1 %>
<TD VALIGN=TOP><% = RS(i) %></TD>
<% Next %>
<TD VALIGN=TOP><% Response.Write("=SUM(S"&(j)&":AC"&(j)&")") %></TD>
<TD VALIGN=TOP><% Response.Write("=(E"&(j)&"-S"&(j)&")/E"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(F"&(j)&"-T"&(j)&")/F"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(G"&(j)&"-U"&(j)&")/G"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(H"&(j)&"-V"&(j)&")/H"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(I"&(j)&"-W"&(j)&")/I"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(J"&(j)&"-X"&(j)&")/J"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(K"&(j)&"-Y"&(j)&")/K"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(L"&(j)&"-Z"&(j)&")/L"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(M"&(j)&"-AA"&(j)&")/M"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(N"&(j)&"-AB"&(j)&")/N"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(O"&(j)&"-AC"&(j)&")/O"&(j)) %></TD>
<TD VALIGN=TOP><% Response.Write("=(P"&(j)&"-AD"&(j)&")/P"&(j)) %></TD>
</TR>
<%
RS.MoveNext
j = j + 1
Loop
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' % Make sure to close the Result Set and the Connection object
' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
RS.Close
%>