Rob_010101
Board Regular
- Joined
- Jul 24, 2017
- Messages
- 198
- Office Version
- 365
- Platform
- Windows
Hello,
I am using the below code, which moves a row to another sheet based upon the value of a drop-down list item.
However, if the data on the sheet the row is moving to is filtered, instead of adding the copied row to the first blank row at the bottom of the data, it overwrites a row of data next in the list. For example, when filtering on Chester, it will overwrite the first row of data where the location is Doncaster, instead of adding the data to the first blank row right at the bottom of the data.
Wondering if someone might know how to get the above to ignore a filter.
Kind Regards
Chris
I am using the below code, which moves a row to another sheet based upon the value of a drop-down list item.
However, if the data on the sheet the row is moving to is filtered, instead of adding the copied row to the first blank row at the bottom of the data, it overwrites a row of data next in the list. For example, when filtering on Chester, it will overwrite the first row of data where the location is Doncaster, instead of adding the data to the first blank row right at the bottom of the data.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim fromRow%, archiveRow%, archiveList As Worksheet
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Target, Range("O2:O500000")) Is Nothing Then 'amend this range address to your
Set archiveList = ThisWorkbook.Worksheets("Archive")
If Target.Value = "Archive" Then
fromRow = ActiveCell.Row
archiveRow = archiveList.Cells(archiveList.Rows.Count, 1).End(3).Row + 1
Range(Cells(fromRow, 1), Cells(fromRow, 15)).Copy archiveList.Cells(archiveRow, 1)
Rows(fromRow).EntireRow.Delete
End If
End If
End Sub
Wondering if someone might know how to get the above to ignore a filter.
Kind Regards
Chris