Advertisement
YasserKhalil2019

T4035_Convert VLOOKUP Formula To VBA

Oct 1st, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. https://excel-egy.com/forum/t4035
  2. ---------------------------------
  3.  
  4. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  5. Dim c As Range
  6.  
  7. If Target.Cells.CountLarge > 1 Then Exit Sub
  8.  
  9. Application.ScreenUpdating = False
  10. Set c = Cells(Target.Row, 1)
  11. If c.Value = Empty Then Exit Sub
  12.  
  13. With c
  14. .Offset(, 1).Formula = "=IFERROR(VLOOKUP(" & c.Address & ",ورقة1!$A$1:$D$12,2,0),"""")"
  15. .Offset(, 2).Formula = "=IFERROR(VLOOKUP(" & c.Address & ",ورقة1!$A$1:$D$12,3,0),"""")"
  16. .Offset(, 3).Formula = "=IFERROR(VLOOKUP(" & c.Address & ",ورقة1!$A$1:$D$12,4,0),"""")"
  17. .Offset(, 1).Resize(1, 3).Value = .Offset(, 1).Resize(1, 3).Value
  18. End With
  19. Application.ScreenUpdating = True
  20. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement