ISNA Formula syntax in VBA

Anne Troy

MrExcel MVP
Joined
Feb 18, 2002
Messages
2,632
Office Version
  1. 365
Platform
  1. Windows
Simply cannot figure out what's wrong. Debug just highlights the whole line. I forget when/where I need double quotes... THANKS!!

Oh, and I just need the formula!

VBA Code:
Sub GetZips()
Dim LastRowColumnA As Long
LastRowColumnA = Cells(Rows.Count, 1).End(xlUp).Row
Range("B2:B" & LastRowColumnA).Formula = "=ISNA(VLOOKUP(A2,datatable,2,0),"Not Found",VLOOKUP(A2,datatable,2,0))"
End Sub
 
Last edited:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
1689918765450.png


I get this error.
 
Upvote 0
Hi Anne

What version of Excel are you using? [I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)]

Do you have the IFNA() function available?
VBA Code:
Range("B2:B" & LastRowColumnA).Formula = "=IFNA(VLOOKUP(A2,datatable,2,0),""Not Found"")"

Otherwise (In post #3 you were missing the second closing parenthesis just before ""Not Found"")
VBA Code:
Range("B2:B" & LastRowColumnA).Formula = "=IF(ISNA(VLOOKUP(A2,datatable,2,0)),""Not Found"",VLOOKUP(A2,datatable,2,0))"
 
Last edited:
Upvote 0
This works in the cell manually:

Excel Formula:
=IF(ISNA(VLOOKUP(b4,datatable,2,0)),"Not Found",VLOOKUP(b4,datatable,2,0))

This throws method of range class failed.

VBA Code:
Sub FormulaFill()
Dim LastRowColumnB As Long
LastRowColumnB = Cells(Rows.Count, 2).End(xlUp).Row

Range("C4:C" & LastRowColumnA).Formula = "=IF(ISNA(VLOOKUP(b4,datatable,2,0)),""Not Found"",VLOOKUP(b4,datatable,2,0))"
End Sub

Thanks for all your help!
 
Upvote 0
Suggest turning Option Explicit on by default .

1689974107923.png


Then you won't get the error you have because of incorrect variable names

1689974187007.png
 
Upvote 0
LOL yep, I just found it, too. THANKS SO MUCH!!!

VBA Code:
Sub FormulaFill()

Dim LastRowColumnB As Long

LastRowColumnB = Cells(Rows.Count, 2).End(xlUp).Row

Range("C4:C" & LastRowColumnB).Formula = "=IF(ISNA(VLOOKUP(b4,datatable,2,0)),""Not Found"",VLOOKUP(b4,datatable,2,0))"

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,094
Messages
6,123,071
Members
449,092
Latest member
ipruravindra

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