Jimgarry
MIS
- May 16, 2000
- 112
Hi, thanks in advance,
I have created an excel spread sheet from with in vb
I am now attempting to put a formula into the spread sheet
for each column. I am haviang a problem referencing the column I want to put in the formula. I use the column number but I think excel is expecting a b c d ... I do not know how may columms I will have in the spread sheet
her is my code: thanks for any advice
Jim
' Get data from the database and insert
' it into the spreadsheet.
row = 2
strTempDept = rs.Fields("empDept"
intRowStart = 2
IntColStart = 3
Do While Not rs.EOF
If rs.Fields("empdept"
= strTempDept Then
' put data into the spread sheet for each department
For col = 0 To rs.Fields.Count - 1
xlsExcelSheet.Cells(row, col + 1) = rs.Fields(col).Value
Next col
intRowEnd = intRowEnd + 1
row = row + 1
rs.MoveNext
Else
' end of department
intRowEnd = row
row = row + 1
xlsExcelSheet.Cells(row, 1) = "Department Totals"
For col = 3 To rs.Fields.Count - 1
' here is where Im having a problem
xlsExcelSheet.Cells(row, IntColStart) = "=sum(" & col & intRowStart & ":" & col & IntColStart & intRowEnd & "
"
Next col
row = row + 2
strTempDept = rs.Fields("empDept"
intRowStart = row
End If
Loop
I have created an excel spread sheet from with in vb
I am now attempting to put a formula into the spread sheet
for each column. I am haviang a problem referencing the column I want to put in the formula. I use the column number but I think excel is expecting a b c d ... I do not know how may columms I will have in the spread sheet
her is my code: thanks for any advice
Jim
' Get data from the database and insert
' it into the spreadsheet.
row = 2
strTempDept = rs.Fields("empDept"
intRowStart = 2
IntColStart = 3
Do While Not rs.EOF
If rs.Fields("empdept"
' put data into the spread sheet for each department
For col = 0 To rs.Fields.Count - 1
xlsExcelSheet.Cells(row, col + 1) = rs.Fields(col).Value
Next col
intRowEnd = intRowEnd + 1
row = row + 1
rs.MoveNext
Else
' end of department
intRowEnd = row
row = row + 1
xlsExcelSheet.Cells(row, 1) = "Department Totals"
For col = 3 To rs.Fields.Count - 1
' here is where Im having a problem
xlsExcelSheet.Cells(row, IntColStart) = "=sum(" & col & intRowStart & ":" & col & IntColStart & intRowEnd & "
Next col
row = row + 2
strTempDept = rs.Fields("empDept"
intRowStart = row
End If
Loop