Hi,
I am new to VBA and having issues trying to cut and paste highlighted rows.
I have started with the below code but it only cuts the active cells rather than the entire rows , I have tried various different bits of code but cant get anything to work.
I need the code to loop through sheet one, find and cut all rows with an offset of 3 for "Date", an offset of 4 for "Staff Id" and an offset of 5 for "Rejected Staff ID"
If anybody could help me with this Id greatly appreciate it.
Thanks,
Sub ErrorList()
'
Dim StartRange As String
Dim EndRange As String
Cells.Find(What:="Date").Select
StartRange = ActiveCell.Address
Selection.Offset(3, 0).Select
EndRange = ActiveCell.Address
ActiveSheet.Range(StartRange & ":" & EndRange).Select
Selection.Cut
Sheets("Sheet2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="Staff ID").Select
StartRange = ActiveCell.Address
Selection.Offset(4, 0).Select
EndRange = ActiveCell.Address
ActiveSheet.Range(StartRange & ":" & EndRange).Select
Selection.Cut
Sheets("Sheet2").Select
ActiveSheet.Paste
Cells.Find(What:="Rejected Staff No:").Select
StartRange = ActiveCell.Address
Selection.Offset(5, 0).Select
EndRange = ActiveCell.Address
ActiveSheet.Range(StartRange & ":" & EndRange).Select
Selection.Cut
Sheets("Sheet2").Select
ActiveSheet.Paste
End Sub
I am new to VBA and having issues trying to cut and paste highlighted rows.
I have started with the below code but it only cuts the active cells rather than the entire rows , I have tried various different bits of code but cant get anything to work.
I need the code to loop through sheet one, find and cut all rows with an offset of 3 for "Date", an offset of 4 for "Staff Id" and an offset of 5 for "Rejected Staff ID"
If anybody could help me with this Id greatly appreciate it.
Thanks,
Sub ErrorList()
'
Dim StartRange As String
Dim EndRange As String
Cells.Find(What:="Date").Select
StartRange = ActiveCell.Address
Selection.Offset(3, 0).Select
EndRange = ActiveCell.Address
ActiveSheet.Range(StartRange & ":" & EndRange).Select
Selection.Cut
Sheets("Sheet2").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Cells.Find(What:="Staff ID").Select
StartRange = ActiveCell.Address
Selection.Offset(4, 0).Select
EndRange = ActiveCell.Address
ActiveSheet.Range(StartRange & ":" & EndRange).Select
Selection.Cut
Sheets("Sheet2").Select
ActiveSheet.Paste
Cells.Find(What:="Rejected Staff No:").Select
StartRange = ActiveCell.Address
Selection.Offset(5, 0).Select
EndRange = ActiveCell.Address
ActiveSheet.Range(StartRange & ":" & EndRange).Select
Selection.Cut
Sheets("Sheet2").Select
ActiveSheet.Paste
End Sub