Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kim Kim is offline
external usenet poster
 
Posts: 12
Default if iserror then value = zero problem

Hi all,

I have the following vba code in Excel 2007

For j = 5 To Range("A5", Range("A5").End(xlDown)).Rows.Count + 4
If IsError(Application.VLookup(Range("A" & j), Range("RASUMMARY"), 2,
False)) Then Range("F" & j).Value = 0 Else
Range("F" & j).Value = Application.VLookup(Range("A" & j),
Range("RASUMMARY"), 2, False)

Next j


The problem is, if the vlookup doesn't exist (iserror), then the value does
not equal zero but shows up as #N/A. I've been beating my head on this
one. Any help is appreciated.
Thanks
Kim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default if iserror then value = zero problem

This worked for me.

Tim

Sub Tester()
Dim r, j

For j = 1 To 3
r = Application.VLookup(Sheet1.Range("D" & j).Value, _
Sheet1.Range("A2:B6"), 2, False)
Sheet1.Range("E" & j).Value = IIf(IsError(r), 0, r)
Next j

End Sub



"Kim" wrote in message
...
Hi all,

I have the following vba code in Excel 2007

For j = 5 To Range("A5", Range("A5").End(xlDown)).Rows.Count + 4
If IsError(Application.VLookup(Range("A" & j), Range("RASUMMARY"), 2,
False)) Then Range("F" & j).Value = 0 Else
Range("F" & j).Value = Application.VLookup(Range("A" & j),
Range("RASUMMARY"), 2, False)

Next j


The problem is, if the vlookup doesn't exist (iserror), then the value
does not equal zero but shows up as #N/A. I've been beating my head on
this one. Any help is appreciated.
Thanks
Kim



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF(ISERROR problem Tony S. Excel Discussion (Misc queries) 3 May 22nd 09 02:18 PM
iserror problem Scott@CW Excel Discussion (Misc queries) 2 September 6th 07 04:24 PM
IF ISERROR John Moore Excel Discussion (Misc queries) 5 June 26th 06 02:01 PM
ISERROR - #NAME? Mpaul Excel Worksheet Functions 2 February 20th 06 10:27 PM
ISERROR Steve P[_4_] Excel Programming 0 June 23rd 04 07:19 AM


All times are GMT +1. The time now is 06:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"