C
chrisnichols87
Can anyone see the problem with the following loop?
The nested loop when on it's own, correctly moves the associated cells
to the 1st record of the sheet "TESTING". However, when put inside the
loop which should do the above for every record, it takes a while and
then errors with:
"Run-time error '1004'
Application defined or object defined error"
The code is:
Dim ca As Long, ta As Long, tb As Long
ca = 3
ta = 1
tb = 1
Dim firstcomplete As Boolean
Dim secondcomplete As Boolean
firstcomplete = False
Do While Cells(ta, 1).Value <> ""
Sheets("CountData").Select
Do While firstcomplete <> True
Sheets("CountData").Select
If Cells(ca, 1).Value = Sheets("TESTING").Cells(ta, 1) Then
Sheets("CountData").Select
Range(Cells(ca, 2), Cells(ca, 99)).Select
Selection.Copy
Sheets("TESTING").Select
Cells(tb, 8).Activate
ActiveSheet.Paste
firstcomplete = True
Else
ca = ca + 1
End If
Loop
ta = ta + 1
tb = tb + 1
ca = 3
firstcomplete = False
Loop
Thanks for any help,
_________________
Chris
The nested loop when on it's own, correctly moves the associated cells
to the 1st record of the sheet "TESTING". However, when put inside the
loop which should do the above for every record, it takes a while and
then errors with:
"Run-time error '1004'
Application defined or object defined error"
The code is:
Dim ca As Long, ta As Long, tb As Long
ca = 3
ta = 1
tb = 1
Dim firstcomplete As Boolean
Dim secondcomplete As Boolean
firstcomplete = False
Do While Cells(ta, 1).Value <> ""
Sheets("CountData").Select
Do While firstcomplete <> True
Sheets("CountData").Select
If Cells(ca, 1).Value = Sheets("TESTING").Cells(ta, 1) Then
Sheets("CountData").Select
Range(Cells(ca, 2), Cells(ca, 99)).Select
Selection.Copy
Sheets("TESTING").Select
Cells(tb, 8).Activate
ActiveSheet.Paste
firstcomplete = True
Else
ca = ca + 1
End If
Loop
ta = ta + 1
tb = tb + 1
ca = 3
firstcomplete = False
Loop
Thanks for any help,
_________________
Chris