I am using the following code to copy data from multiple tabs to a summary tab - it is only supposed to copy the data in the rows if the cells in Column A have data in them, its working, but for some reason it is copying the data in columns Y and Z for four extra rows even though there is no data in column A for those rows.....driving me crazy! I am attaching a sample of the workbook here as well - hoping someone can figure out what I have coded wrong
I am working in Office 2007.
Sub SumData()
'
' SummarizeData from Timesheets
'
Sheets("Jorge Montoya").Select
Range("A9").Select
Set r = Range("A9:A27")
For n = 1 To r.Rows.Count
myval = ActiveCell.Value
If InStr(myval, "") > 0 Then
ActiveCell.Range("A1:Z1").Select
Selection.Copy
Sheets("Total by Job_Code").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=True, Transpose:=False
ActiveCell.Offset(1, 0).Select
End If
Sheets("Jorge Montoya").Select
ActiveCell.Offset(1, 0).Select
Next n
Range("A9").Select
Sheets("Felipe Estrada").Select
Range("A9").Select
Set r = Range("A9:A27")
For n = 1 To r.Rows.Count
myval = ActiveCell.Value
If InStr(myval, "") > 0 Then
ActiveCell.Range("A1:Z1").Select
Selection.Copy
Sheets("Total by Job_Code").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=True, Transpose:=False
ActiveCell.Offset(1, 0).Select
End If
Sheets("Felipe Estrada").Select
ActiveCell.Offset(1, 0).Select
Next n
Range("A9").Select
Sheets("Kimberly Garcia").Select
Range("A9").Select
Set r = Range("A9:A27")
For n = 1 To r.Rows.Count
myval = ActiveCell.Value
If InStr(myval, "") > 0 Then
ActiveCell.Range("A1:Z1").Select
Selection.Copy
Sheets("Total by Job_Code").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=True, Transpose:=False
ActiveCell.Offset(1, 0).Select
End If
Sheets("Kimberly Garcia").Select
ActiveCell.Offset(1, 0).Select
Next n
Range("A9").Select
End Sub
There will end up being about 30 different tabs that it will need to copy from, but the attachment I am including only has 3.
Thank you in advance for any help!
Bookmarks