A macro to move or copy a row with a condition

aysam

Board Regular
Joined
Jun 24, 2009
Messages
224
Office Version
  1. 2010
Platform
  1. Windows
Hi All
I need a macro to move or copy any row that has the word (( moved )) to another sheet with the same name.
the file has thousands of rows.
thanks in advance
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Aysam_1(1) (1).xlsm
ABCDEFGHIJKL
7مالاســــــــــمالنوعتاريخ الميلاديومشهرسنةالديانةالمدرسة الابتدائيحالة القيدالتحويلالفصل
81احمد محمد احمد محمد السيدذكر   مسلماسامة بن زيدمستجد
92احمد محمد ذكي محفوظ الشريفذكر   مسلماسامة بن زيدمستجد
103احمد محمد فتحي عزب محمدذكر   مسلماسامة بن زيدمستجد
114احمد محمد لطفي محمد علي بركاتذكر   مسلماسامة بن زيدمستجد
125احمد محمد محمود ياسين النشارذكر   مسلماسامة بن زيدمستجد
136احمد محمود حسن محمود حسنذكر   مسلماسامة بن زيدمستجد
البيانات
 
Upvote 0
Unfortunately, I can't work with the screen shot you posted because I don't understand your language.
 
Upvote 0
Thanks so much
I tried this line of code you offered
.Range("A2:L" & LastRow).SpecialCells(xlCellTypeVisible).Delete shift:=xlUp
but It still deletes the entire row
What I need
is to delete the range.( A: L ). in sheet 1
Hope I'm clear
 
Upvote 0
Try:
VBA Code:
Sub MoveRows()
    Application.ScreenUpdating = False
    Dim LastRow As Long, srcWS As Worksheet, desWS As Worksheet, rng As Range
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Set srcWS = Sheets("Sheet1")
    Set desWS = Sheets("Moved")
    With srcWS
        .Cells(1, 1).CurrentRegion.AutoFilter 6, "moved"
        .AutoFilter.Range.Offset(1).Copy desWS.Cells(desWS.Rows.Count, "A").End(xlUp).Offset(1)
        Set rng = .Range("A2:L" & LastRow).SpecialCells(xlCellTypeVisible)
        .Range("A1").AutoFilter
        rng.Delete shift:=xlUp
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

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