Do Until rs.EOF 'This piece does not allow the TO to repeat. If the TO is repeated, then it will just move to the next record until it finds one that does not repeat If rs!TO = TheTO Then 'Same with the STO. Keeps the STO from repeating. If the STO is a duplicate, it goes to the next one. If rs!STO = TheSTOname Then 'If the staff name duplicates, then it goes to the next record. THIS IS A PROBLEM. I need the staff names to repeat with the STOs If TheStaffName = rs!TeamName Then 'If the ActDesc repeats, it will move to the next line. If theActDesc = rs!ActDesc Then rs.MoveNext Else 'Starts writing the ActDesc to the spreadsheet theRow = theRow + 1 oSheet.Cells(theRow, 4).Value = rs!ActDesc rs.MoveNext End If Else 'Starts moving the staff names to the spreasheet. I want these connected to the sto name. theRow = theRow + 1 oSheet.Cells(theRow, 3).Value = rs!TeamName TheStaffName = rs!TeamName rs.MoveNext End If Else theRow = theRow + 1 oSheet.Cells(theRow, 2).Value = rs!STO TheSTOname = rs!STO rs.MoveNext End If Else theRow = theRow + 1 oSheet.Cells(theRow, 1).Value = rs!TO TheTO = rs!TO rs.MoveNext End If skip: Loop
From novice to tech pro — start learning today.