What is the behavior of using this method to export data to excel from access. This works fine, if I make 2 more Dim j and Dim k and use those for the 2nd and 3rd loops. I have to do this about 6 times more. But when the excel file opens the cells that the data goes into is all over the place, keeps going farther and farther down the rows.
I thought the statement of i = 10 will start at that row, but if I use it in another loop it changes. Do I need to "reset" the value of i back to 10 after each loop? Since I use the i + 1 in the loop?
I can post the whole sub routine if needed.
I thought the statement of i = 10 will start at that row, but if I use it in another loop it changes. Do I need to "reset" the value of i back to 10 after each loop? Since I use the i + 1 in the loop?
Code:
[FONT=Verdana]Dim i As Integer[/FONT]
[FONT=Verdana]i = 10 'First Row: CmtAwd[/FONT]
[FONT=Verdana]With xlWks[/FONT]
[FONT=Verdana]Do While Not rsCmtAwd.EOF[/FONT]
[FONT=Verdana].Range("E" & i - 1).Value = Nz(rsCmtAwd!FullName, "")[/FONT]
[FONT=Verdana]i = i + 1[/FONT]
[FONT=Verdana]rsCmtAwd.MoveNext[/FONT]
[FONT=Verdana]Loop[/FONT]
[FONT=Verdana]End With[/FONT]
[FONT=Verdana]With xlWks[/FONT]
[FONT=Verdana]Do While Not rsCmtJawsChair.EOF[/FONT]
[FONT=Verdana].Range("Y9").Value = (rsCmtJawsChair!FullNameChair)[/FONT]
[FONT=Verdana]rsCmtJawsChair.MoveNext[/FONT]
[FONT=Verdana]Loop[/FONT]
[FONT=Verdana]End With[/FONT]
[FONT=Verdana]With xlWks[/FONT]
[FONT=Verdana]Do While Not rsCmtJaws.EOF[/FONT]
[FONT=Verdana].Range("Y" & i).Value = Nz(rsCmtJaws!FullName, "")[/FONT]
[FONT=Verdana]i = i + 1[/FONT]
[FONT=Verdana]rsCmtJaws.MoveNext[/FONT]
[FONT=Verdana]Loop[/FONT]
[FONT=Verdana]End With[/FONT]
[FONT=Verdana]With xlWks[/FONT]
[FONT=Verdana]Do While Not rsCmtSickChair.EOF[/FONT]
[FONT=Verdana].Range("AS9").Value = (rsCmtSickChair!FullNameChair)[/FONT]
[FONT=Verdana]rsCmtSickChair.MoveNext[/FONT]
[FONT=Verdana]Loop[/FONT]
[FONT=Verdana]End With[/FONT]
[FONT=Verdana]With xlWks[/FONT]
[FONT=Verdana]Do While Not rsCmtSick.EOF[/FONT]
[FONT=Verdana].Range("AS" & i).Value = Nz(rsCmtSick!FullName, "")[/FONT]
[FONT=Verdana]i = i + 1[/FONT]
[FONT=Verdana]rsCmtSick.MoveNext[/FONT]
[FONT=Verdana]Loop[/FONT]
[FONT=Verdana]End With[/FONT]
I can post the whole sub routine if needed.