Hi,
I have the code below that I was trying to use to flag addresses where the state was AK or HI (State is in Col J on sheet Address Details). I am trying to copy all of these values to the sheet AK_HI Records but I keep getting a runtime error.
Any help here would be greatly appreciated.
Sub H_Copy_AK_HI()
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("AK", "HI")
Set wsSource = ActiveSheet
NoRows = wsSource.Range("A100000").End(xlUp).Row
DestNoRows = 1
Set wsDest = ActiveWorkbook.Sheets("AK_HI Records")
For I = 1 To NoRows
Set rngCells = wsSource.Range("I" & J & ":I" & J)
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
Sheets("Address Details").Select
End Sub
I have the code below that I was trying to use to flag addresses where the state was AK or HI (State is in Col J on sheet Address Details). I am trying to copy all of these values to the sheet AK_HI Records but I keep getting a runtime error.
Any help here would be greatly appreciated.
Sub H_Copy_AK_HI()
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("AK", "HI")
Set wsSource = ActiveSheet
NoRows = wsSource.Range("A100000").End(xlUp).Row
DestNoRows = 1
Set wsDest = ActiveWorkbook.Sheets("AK_HI Records")
For I = 1 To NoRows
Set rngCells = wsSource.Range("I" & J & ":I" & J)
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
Sheets("Address Details").Select
End Sub