Hi- I looked at other examples and tested, but I couldn't get it to work. I need to copy and paste the columns from Employees to Sheet1 based on cell value from my Users sheet. Please review my codeand tell me what I need to do. This code pastes all rows instead of the columns I need (columns A - F) only and it only pasted 1 row instead of all rows that met the criteria.
Thanks-
#Sub Import_EMP()
Sheets("Employees").Visible = True
Sheets("Employees").Unprotect ("jethro")
Sheets("Employees").Activate
Sheets("Users").Visible = True
Sheets("Users").Unprotect ("jethro")
Sheets("Users").Activate
Dim r As Integer
Dim i As Integer
r = 5
For i = Selection.Rows.Count + 1 To Step - 1
If Range("A" & i).Value = Sheets("Sheet1").Range("A2").Value Then
Range("A" & i).EntireRow.Copy Sheets("Sheet1").Cells(r, 1)
r = r + 1
End If
Next
'Sheets("Employees").Activate
'Sheets("Employees").Protect ("jethro")
End Sub#
Thanks-
#Sub Import_EMP()
Sheets("Employees").Visible = True
Sheets("Employees").Unprotect ("jethro")
Sheets("Employees").Activate
Sheets("Users").Visible = True
Sheets("Users").Unprotect ("jethro")
Sheets("Users").Activate
Dim r As Integer
Dim i As Integer
r = 5
For i = Selection.Rows.Count + 1 To Step - 1
If Range("A" & i).Value = Sheets("Sheet1").Range("A2").Value Then
Range("A" & i).EntireRow.Copy Sheets("Sheet1").Cells(r, 1)
r = r + 1
End If
Next
'Sheets("Employees").Activate
'Sheets("Employees").Protect ("jethro")
End Sub#