Need Code Review to Copy all rows and paste to next sheet.

shahao

New Member
Joined
Feb 13, 2021
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
I have an excel file with rows of more than 300,000, I need a macro code that copies all rows and paste them to a new sheet if any column has SPECIAL TEXT, the sheet has multiple columns from A-N,
I found a code that works on the same principle, but I don't know why It's not working in my case,
code is from this forum by (NORIE).

VBA Code:
Sub BankMove()
Dim strArray As Variant
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Dim NoRows As Long
Dim DestNoRows As Long
Dim I As Long
Dim J As Integer
Dim rngCells As Range
Dim rngFind As Range
Dim Found As Boolean
   
    strArray = Array("bank", "KLM", "firm")
   
    Set wsSource = ActiveSheet
   
    NoRows = wsSource.Range("A65536").End(xlUp).Row
    DestNoRows = 1
    Set wsDest = ActiveWorkbook.Worksheets.Add
       
    For I = 1 To NoRows
   
        Set rngCells = wsSource.Range("C" & I & ":F" & I)
        Found = False
        For J = 0 To UBound(strArray)
            Found = Found Or Not (rngCells.Find(strArray(J)) Is Nothing)
        Next J
       
        If Found Then
            rngCells.EntireRow.Copy wsDest.Range("A" & DestNoRows)
           
            DestNoRows = DestNoRows + 1
        End If
    Next I
End Sub


Please help me with this.
Thanks.
 

Attachments

  • Screenshot_6.png
    Screenshot_6.png
    66.8 KB · Views: 5

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,562
Office Version
  1. 365
Platform
  1. Windows
Which columns do you need to check for those 3 keywords?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,141,715
Messages
5,708,030
Members
421,540
Latest member
quocbinh

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
Top