move rows based on cell criteria from sheet to another

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,430
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hi
i have this code works well i would if is possible to make it copy rows what contains "not available" in one time in my case i have to press every time each row contains "not available " i find this is not practical and take me more time if i have 1000 rows of data
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F:F")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("RESULT").Cells(Rows.Count, "F").End(xlUp).Row + 1

If Target.Value = "NOT AVAILABLE" Then
Rows(Target.Row).Copy Destination:=Sheets("RESULT").Rows(Lastrow)
Rows(Target.Row).Delete
End If
End If
End Sub
thanks
 
I changed the sode slightly and it seems to be more reliable. Give this a try.
VBA Code:
Sub notAvail()
Dim rng As Range
With Sheets("Data")
    .UsedRange.AutoFilter 6, "Not available"
    Set rng = .UsedRange.SpecialCells(xlCellTypeVisible)
    If Not rng Is Nothing Then
        Sheets("RESULT").UsedRange.ClearContents 'Removes old data from sheet
        rng.Copy Sheets("RESULT").Range("A1")
    End If
    Set rng = .UsedRange.Offset(1).SpecialCells(xlCellTypeVisible)
    rng.EntireRow.Delete
    .AutoFilterMode = False
End With
End Sub
 
Upvote 0
Solution

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
for me i prefer your codes in post#2,4 any way thanks for your effort and time
best regards
abdelfattah
 
Upvote 0

Forum statistics

Threads
1,215,657
Messages
6,126,057
Members
449,284
Latest member
fULMIEX

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top