Hello,
I have the below code that works, however it only posts the first row into the sheet and not every row that meets the condition in column P. Essentially I am trying to search Open POs Finance column P for all rows that have a result that matches the value in Critique A23 (although if I can also not have it reference a cell and instead just search for Not Accrued text that would be great). The macro works, however it is only copying the first row that it hits that meets the criteria and does not copy and paste other rows below it.
Sub CopyData()
Application.ScreenUpdating = False
Dim srcWS As Worksheet, desWS As Worksheet, fnd As Range, colArr As Variant
colArr = Array("B", "A", "F", "B", "H", "C", "J", "D", "K", "E", "M", "F")
Set desWS = Sheets("Critique")
Set srcWS = Sheets("Open POs Finance")
Set fnd = srcWS.Range("P:P").Find(desWS.Range("A23").Value, LookIn:=xlValues, lookat:=xlWhole)
If Not fnd Is Nothing Then
For i = LBound(colArr) To UBound(colArr) Step 2
srcWS.Range(colArr(i) & fnd.Row).Copy desWS.Cells(desWS.Rows.Count, colArr(i + 1)).End(xlUp).Offset(1)
Next i
Else
MsgBox desWS.Range("A23") & " not found."
End If
Application.ScreenUpdating = True
End Sub
I have the below code that works, however it only posts the first row into the sheet and not every row that meets the condition in column P. Essentially I am trying to search Open POs Finance column P for all rows that have a result that matches the value in Critique A23 (although if I can also not have it reference a cell and instead just search for Not Accrued text that would be great). The macro works, however it is only copying the first row that it hits that meets the criteria and does not copy and paste other rows below it.
Sub CopyData()
Application.ScreenUpdating = False
Dim srcWS As Worksheet, desWS As Worksheet, fnd As Range, colArr As Variant
colArr = Array("B", "A", "F", "B", "H", "C", "J", "D", "K", "E", "M", "F")
Set desWS = Sheets("Critique")
Set srcWS = Sheets("Open POs Finance")
Set fnd = srcWS.Range("P:P").Find(desWS.Range("A23").Value, LookIn:=xlValues, lookat:=xlWhole)
If Not fnd Is Nothing Then
For i = LBound(colArr) To UBound(colArr) Step 2
srcWS.Range(colArr(i) & fnd.Row).Copy desWS.Cells(desWS.Rows.Count, colArr(i + 1)).End(xlUp).Offset(1)
Next i
Else
MsgBox desWS.Range("A23") & " not found."
End If
Application.ScreenUpdating = True
End Sub