Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF=IFERROR(VLOOKUP

Status
Not open for further replies.

jgarvey23

Technical User
Jul 9, 2015
10
US
Hi All,

My below code performs a Vlookup based on an IF statement then adds 1 to the prior day business sheet if found. Except, if not found, it returns an #N/A & I have to manually change every cell to 1.

I've tried everything e.g =IF(ISERROR(VLOOKUP, =IF(ISERROR(VLOOKUP.. No success.

Any ideas and/or solutions would help!

Code:
'Days Vlookup
    Range("E2").Formula = _
        "=IF(VLOOKUP(C[-2],'[PBDunkAcc.xlsx]Shell'!C3:C5,3,FALSE),VLOOKUP(C[-2],'[PBDunkAcc.xlsx]Shell'!C3:C5,3,FALSE)+1,1)"
    Range("E2").Select
 
Hi

Use IFERROR() assuming that you have Excel version 2007 or greater.

[tt]
=IFERROR(Your vlookup,Your error return value)
[/tt]
 
Skip,

My current formula
Code:
,'[PBDunkAcc.xlsx]Shell'!C3:C5,3,FALSE),VLOOKUP(C[-2],'[PBDunkAcc.xlsx]Shell'!C3:C5,3,FALSE)+1,1)"]

will always increase the prior day value by 1 if present. Except, the IFERROR option won't increase by 1, only change #N/A..

Do you know a way to build that functionality in or another method to keep the structure of my vlookup to increase the value if found & if not then put 1.

e.g.. Yesterdays spreadsheet had 15 for Security 2323232, this morning it will show 16 (Yesterday +1). I need the new formula/ method to do the same plus change errors to 1....
 
Well if you can't find it how can you add 1 to nothing?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
It logically seems that if the lookup returns N/A, the PREVIOUS cell's value might be returned.

But then I can't see your sheet/data, so that might be an incorrect assumption.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top