I have the following code:
Dim prevSht As Worksheet
Dim foundCell As Range
Dim foundCol As Long
Dim findStr As String
Dim findRng As Range
Set prevSht = Worksheets("Previous_OnPrem")
findStr = "Date"
Set findRng = prevSht.Range("A:J")
Set foundCell = findRng.Find(What:=findStr, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
ActiveCell.Value = "=IFERROR(VLOOKUP(" & Range("G2").Address(0, 0) & ",Previous_OnPrem!A:J, " & foundCell.Column & "),"""")"
ActiveCell.AutoFill Destination:=Range(ActiveCell.Address & ":" & "A" & RowCount)
I would like the blank cells to return as Blank
When VLOOKUP
doesn't find a matching value, it works properly, but when it does find a match, the blank cells associated returns 0
.
I found this similar example as solution to fix it, when it's a simple VLookup
=IF(VLOOKUP(E3,$B$2:$C$7,2,FALSE))=0,"",VLOOKUP(E3,$B$2:$C$7,2,FALSE)
I've tried to adapt it with my actual code in many different ways, but couldn't get it to work.