Godders199
Active Member
- Joined
- Mar 2, 2017
- Messages
- 313
- Office Version
- 2013
Hello, I am always recording and adding vlookup into Marco's as below, I will like to understand how to write it within vba rather than recording everything, also if possible how only to put the result in the cell , rather than the formula.
the basic formula is
=IFERROR(VLOOKUP(AB2,'SQ Hierarchy'!A:C,3,FALSE),"")
My current code when i add to by vba is
Dim LR1 As Long
LR1 = Range("a" & Rows.Count).End(xlUp).Row
Range(“z2”).select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(RC[2],'SQ Hierarchy'!C[-25]:C[-23],3,FALSE),"""")"
Range("Z3").Select
Range("z2").Copy
Range("z3:z" & LR1).PasteSpecial xlPasteAll
Application.CutCopyMode = False
This is just one example, of the 10 I need to add in, I am just looking to progress my knowledge and make my VBA look more professional
I have tried working through some examples i have found online but they never seem to work when adapting to my worksheets.
Any help would be appreciated
the basic formula is
=IFERROR(VLOOKUP(AB2,'SQ Hierarchy'!A:C,3,FALSE),"")
My current code when i add to by vba is
Dim LR1 As Long
LR1 = Range("a" & Rows.Count).End(xlUp).Row
Range(“z2”).select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(RC[2],'SQ Hierarchy'!C[-25]:C[-23],3,FALSE),"""")"
Range("Z3").Select
Range("z2").Copy
Range("z3:z" & LR1).PasteSpecial xlPasteAll
Application.CutCopyMode = False
This is just one example, of the 10 I need to add in, I am just looking to progress my knowledge and make my VBA look more professional
I have tried working through some examples i have found online but they never seem to work when adapting to my worksheets.
Any help would be appreciated