I know using Select is bad.
I'm trying to select cells from only the first row when multiple results are returned after autofiltering. I've used xlCellTypeVisible
to copy all of the visible rows, but I'm unsure of how I could make this select cells in the C and D columns in the first filtered row. I would be taking values from the second autofilter before the activecellOffset lines.
For i = 2 To k
Sheets("Database").Select
ActiveSheet.Range("$A$1:$C" & k).AutoFilter Field:=2, Criteria1:= _
Worksheets("SoPhiH").Range("A" & i).Value, Operator:=xlAnd
Sheets("Database").Select
ActiveSheet.Range("$A$1:$R" & k).AutoFilter Field:=5, Criteria1:= _
Worksheets("SoPhiH").Range("C" & i).Value, Operator:=xlAnd
Sheets("Database").Select
If Application.WorksheetFunction.Subtotal(3, Range("A2:A" & k)) Then ' If the cell is blank copy and paste, else do nothing
Else
ActiveSheet.Range("$A$1:$C" & k).AutoFilter Field:=2
ActiveSheet.Range("$A$1:$C" & k).AutoFilter Field:=5
Sheets("SoPhiH").Select
ActiveSheet.Range("A" & i).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Database").Select
Range("B" & Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste
UWI = ActiveCell.Value
ActiveSheet.Range("$A$1:$C" & k).AutoFilter Field:=2, Criteria1:= _
UWI, Operator:=xlAnd
ActiveCell.Offset(0, 3) = Worksheets("SoPhiH").Range("C" & i)
ActiveCell.Offset(0, 17) = Worksheets("SoPhiH").Range("B" & i)
End If
Next i