Advertisement
YasserKhalil2019

YT_Match In Merged Cells By MergeArea YasserKhalil

Jan 3rd, 2020
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. https://www.youtube.com/watch?v=1g1bPYC4V-A
  2. -------------------------------------------
  3.  
  4. Sub Match_In_Merged_Cells_By_MergeArea_YasserKhalil()
  5. Dim x, r As Range, c As Range, lr As Long
  6. Const iRow As Integer = 4
  7.  
  8. lr = Cells(Rows.Count, 1).End(xlUp)(2).Row
  9. x = Application.Match(Range("G2").Value, Rows(iRow), 0)
  10.  
  11. If Not IsError(x) Then
  12. Set r = Cells(iRow + 1, x).Resize(, Cells(iRow + 1, x).Offset(-1).MergeArea.Count)
  13. For Each c In r
  14. If c.Value = Range("F2").Value Then
  15. Cells(lr, 1).Value = Range("C2").Value
  16. Cells(lr, 2).Value = Range("D2").Value
  17. Cells(lr, c.Column).Value = Range("E2").Value
  18. Exit For
  19. End If
  20. Next c
  21. End If
  22. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement