Your this code works like a charm.!! Thank you so much for your assistance.
One tweak request. I wanted the same code in another my project but your code is tricky for me to tweak to my preference. I never understood the concept of X & Y even on my school
Here what I have in another spreadsheet.
1) Instead of column C of lookup search in Sheet2, I would like to replace lookup search to column B (Sheet2).
2) Instead of Column G (Yes) in sheet2, this time I want Column C "No"
3) Keep the C & D as it is, as I will be copying cell C & D from sheet2
4) Data to be pasted in P & Q of Sheet1 ( Earlier it was O & P )
your code below for easy reference.
Sub trans()
Dim x, y(), i&, j&, k&, ms As Worksheet
Set ms = Sheets("Sheet1")
x = Sheets("Sheet2").Range("A1:H" & Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row)
ReDim y(1 To UBound(x, 1) * UBound(x, 1), 1 To 2)
For i = 2 To UBound(x, 1)
If x(i, 3) = ms.Range("N2") And x(i, 7) = "Yes" Then
k = k + 1
y(k, 1) = x(i, 3)
y(k, 2) = x(i, 4)
End If
Next i
ms.Range("O2").Resize(k, 2).Value = y()
End Sub
Thank you so much for your help. You are the best!
Regards
Shiva
Bookmarks