I would love some guidance on how to fix my copy and paste code in the sub that I have pasted below. I know I am probably overlooking something obvious, but I haven't been able to crack it on my own. Any help would be greatly appreciated.
What I am trying to do here is look through each row on each sheet in a workbook. If the value in column D is 1 AND the value in column E is yes, I want to copy the text in column A to the next free row on the top worksheet (sheet 1).
Some of this works, and some doesn't. I think that it is reliably finding the 1s in column D. I fear it may not be finding the "yes"s in column E. And in some cases it is copying the right text from column A, but it has never once pasted that text to the top sheet.
Thanks in advance!
[FONT="]Sub Compile()[/FONT]
[FONT="] Dim S As Integer[/FONT]
[FONT="] Dim i As Integer[/FONT]
[FONT="] For S = 2 To Sheets.Count[/FONT]
[FONT="] Worksheets(S).Activate[/FONT]
[FONT="] For i = 1 To 5[/FONT]
[FONT="] If Worksheets(S).Cells(i, 4).Value = 1 Then[/FONT]
[FONT="] MsgBox "Found a 1!"[/FONT]
[FONT="] If Worksheets(S).Cells(i, 5).Value = yes Then[/FONT]
[FONT="] MsgBox "Found a yes!"[/FONT]
[FONT="] Worksheets(S).Cells(i, 1).Copy[/FONT]
[FONT="] Worksheets(1).Range("A250").End(x1Up).Offset(1, 0).Paste[/FONT]
[FONT="] MsgBox "Got Here"[/FONT]
[FONT="] End If[/FONT]
[FONT="] End If[/FONT]
[FONT="] Next i[/FONT]
[FONT="] Next S[/FONT]
[FONT="]End Sub[/FONT]
What I am trying to do here is look through each row on each sheet in a workbook. If the value in column D is 1 AND the value in column E is yes, I want to copy the text in column A to the next free row on the top worksheet (sheet 1).
Some of this works, and some doesn't. I think that it is reliably finding the 1s in column D. I fear it may not be finding the "yes"s in column E. And in some cases it is copying the right text from column A, but it has never once pasted that text to the top sheet.
Thanks in advance!
[FONT="]Sub Compile()[/FONT]
[FONT="] Dim S As Integer[/FONT]
[FONT="] Dim i As Integer[/FONT]
[FONT="] For S = 2 To Sheets.Count[/FONT]
[FONT="] Worksheets(S).Activate[/FONT]
[FONT="] For i = 1 To 5[/FONT]
[FONT="] If Worksheets(S).Cells(i, 4).Value = 1 Then[/FONT]
[FONT="] MsgBox "Found a 1!"[/FONT]
[FONT="] If Worksheets(S).Cells(i, 5).Value = yes Then[/FONT]
[FONT="] MsgBox "Found a yes!"[/FONT]
[FONT="] Worksheets(S).Cells(i, 1).Copy[/FONT]
[FONT="] Worksheets(1).Range("A250").End(x1Up).Offset(1, 0).Paste[/FONT]
[FONT="] MsgBox "Got Here"[/FONT]
[FONT="] End If[/FONT]
[FONT="] End If[/FONT]
[FONT="] Next i[/FONT]
[FONT="] Next S[/FONT]
[FONT="]End Sub[/FONT]