Advertisement
YasserKhalil2019

T4011_Transfer Data By Application Match Tutorial

Sep 28th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. https://excel-egy.com/forum/t4011
  2. ---------------------------------
  3.  
  4. 'In Worksheet (RESULT) Module
  5. '----------------------------
  6. Private Sub Worksheet_Change(ByVal Target As Range)
  7. If Not Intersect(Range("C2"), Target) Is Nothing Then
  8. Call Transfer_Data
  9. End If
  10. End Sub
  11.  
  12. 'In Standard Module
  13. '------------------
  14. Sub Transfer_Data()
  15. Dim x, ws As Worksheet, sh As Worksheet
  16.  
  17. Application.ScreenUpdating = False
  18. Set ws = ThisWorkbook.Worksheets("DATA")
  19. Set sh = ThisWorkbook.Worksheets("RESULT")
  20.  
  21. x = Application.Match(sh.Range("C2").Value, ws.Columns(1), 0)
  22. If Not IsError(x) Then
  23. With sh
  24. .Range("C3").Value = ws.Cells(x, 6).Value
  25. .Range("C4").Value = ws.Cells(x, 2).Value
  26. .Range("I2").Value = ws.Cells(x, 9).Value
  27. .Range("I4").Value = ws.Cells(x, 5).Value
  28. End With
  29. Else
  30. sh.Range("C3,C4,I2,I4").Value = ""
  31. MsgBox "Number Not Exists", vbExclamation
  32. End If
  33. Application.ScreenUpdating = True
  34. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement