hi guys need your help.
I have a problem in using the 'find-copy and loop' method,
here's my data:
<tbody>
</tbody>
and this is the code I used:
what happens is:
The code does not copy all the results that I found. whereas, based on the above data should be there around 9 results but that appears there's only 8 results. what is lacking or wrong of my code.?
thanks before.
I have a problem in using the 'find-copy and loop' method,
here's my data:
A | B | C | D | E | F | G | |
1 | Name 1 | A1 | OK | A2 | OK | - | - |
2 | Name 2 | B1 | OK | - | - | - | - |
3 | Name 3 | C1 | OK | C2 | OK | C3 | OK |
4 | Name 4 | D1 | OK | - | - | D3 | OK |
5 | Name 5 | E1 | OK | - | - | - | - |
6 | .... |
<tbody>
</tbody>
and this is the code I used:
Code:
Sub Copas()
Dim DestSheet As Worksheet
Set DestSheet = Worksheets("Sheet2")
Dim sRow As Long
Dim dRow As Long
Dim sCount As Long
Dim X As Long
sCount = 0
dRow = 1
X = 1
Do Until Cells(X, 1) = ""
For sRow = Cells(X, 1) To Cells(X, 1000).End(xlToRight).Column
If Cells(X, sRow) Like "*OK*" Then
sCount = sCount + 1
dRow = dRow + 1
Cells(X, 1).Copy Destination:=DestSheet.Cells(dRow, "A")
Cells(X, sRow).Copy Destination:=DestSheet.Cells(dRow, "B")
Cells(X, sRow - 1).Copy Destination:=DestSheet.Cells(dRow, "C")
End If
Next sRow
X = X + 1
Loop
End Sub
what happens is:
The code does not copy all the results that I found. whereas, based on the above data should be there around 9 results but that appears there's only 8 results. what is lacking or wrong of my code.?
thanks before.