ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programming around vlookup errors in vba (https://www.excelbanter.com/excel-programming/369040-programming-around-vlookup-errors-vba.html)

Elceller in distress

Programming around vlookup errors in vba
 
I have a program that uses vlookup to find values that are stored in a quote
that is made in excel. Some of the older quotes do no contain all of the
fields (Lookup_Values) that are in the newer quotes. When this occurs, the
excel macro stops and highlights the vlookup function that I am using. Is
there a way to use?
if(iserror(vlookup))then... or any other functions to work around this
problem? If the field does not exist, I would like it to return "" to the
active cell. The program works fine when all of the fields (Lookup_values)
are on the quote.

Code:
Dim ArmatureRange As Range
Set ArmatureRange = Worksheets("Sheet1").Range("H:J")
Armature = (Application.WorksheetFunction.Vlookup("Arm:", ArmatureRange,
3, False))

ActiveCell.Formula = Armature




All times are GMT +1. The time now is 01:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com