I get a spreadsheet daily that has thousands of lines in it. In the first column are account codes. I am responsible for a few dozen accounts so the majority of the spreadsheet is information I do not need. What I would like to do is run a macro that simply copies all the row related to my accounts from the first sheet over to the blank second sheet. I believe I found code (from Norie on this site - posted below) that could be modified. My concern is that it appears to be looking through the entire spreadsheet (there are numbers everywhere) and I need to limit it to only looking in Column A. Also I went ahead and modified it by putting my account numbers where the Array("bank", "KLM", "firm") part is so it now reflected strArray = Array("000103", "000330", "000665"). When I ran the macro it correctly copied the 2 rows of 000103 and the only row of 000330, but it failed to copy the row for 000665.
If anyone can help guide me, I'd greatly appreciate it.
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
If anyone can help guide me, I'd greatly appreciate it.
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