How can i write in vba the If(isna(vlookup(...) function?

Hernan_g_f

New Member
Joined
Jul 26, 2022
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Dear all,

I have three columns

A B C
1 1
2 4
3 7
4
5
6
7

I need to write in VBA at column B = If (isna(vlookup(Cells(i,"ColumnA").Value, Range(C1:C100),1,0)),""; vlookup(Cells(i,"ColumnA").Value, Range(C1:C100),1,0))

How can I do it? Thanks in advance!
 
Dim s9 as Worksheet
Dim sa, s9 As Worksheet
Set s9 = Sheets("9")
Set sa = Sheets("A")

I'm using to develop a methodology to use time series :)
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Michael,

When I try to use your macro, a message appears again: "Compile error: Sub or Function not defined" and the program indicates the first "vlookup" at the right of IsNa

For i = 27 To x2 + 27
s9.Select
Cells(i, 16).Value = WorksheetFunction.If(IsNA(VLookup(Cells(i, 3).Value, Range("BC16:BC100"), 1, 0)), """", VLookup(Cells(i, 3).Value, Range("BC16:BC100"), 1, 0))
Next i

With r3
.Value = .Value
End With
 
Upvote 0
Try replacing your lookup line with these 3 lines:

VBA Code:
    With Application
        Cells(i, 16).Value = .IfError(.VLookup(Cells(i, 3).Value, Range("BC16:BC100"), 1, 0), "")
    End With
 
Upvote 1
Solution
Try replacing your lookup line with these 3 lines:

VBA Code:
    With Application
        Cells(i, 16).Value = .IfError(.VLookup(Cells(i, 3).Value, Range("BC16:BC100"), 1, 0), "")
    End With
Thank you!!!!!! Very much!!!!!!!! Is running !!! Excellent!!! Best! Hernán!!!
 
Upvote 0
Thank you!!!!!! Very much!!!!!!!! Is running !!! Excellent!!! Best! Hernán!!!
The marked solution has been changed accordingly. In your future questions, please mark the post as the solution that actually answered your question, instead of your feedback message as it will help future readers. No further action is required for this thread.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,275
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top