LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Vlookup and Type Mismatch

That's why I dropped the .worksheetfunction in the code I suggested.

And that's why I suggested this:

I'd add:
if iserror(stiprice) then
'no match, what should happen
else
'keep going
end if

If you return an error, what should happen he

If Security = "SunTrust Common Stock Fund" Then
.Offset(CountRows, 7) = Amount / STIPrice
Else: .Offset(CountRows, 7) = UnitsShares
End If

Maybe...

If Security = "SunTrust Common Stock Fund" Then
if iserror(stiprice) then
.offset(countrows,7) = "stiprice not found!"
else
if isnumber(stiprice) = false then
.offset(countrows,7) = "Stiprice not a number!"
else
if stiprice = 0 then
.offset(countrows,7) = "Stiprice = 0"
else
.Offset(CountRows, 7) = Amount / STIPrice
end if
end if
end if
Else
.Offset(CountRows, 7) = UnitsShares
End If


John Pierce wrote:

WorksheetFunction doesn’t work at all. I had to change to
“Application.Vlookup”. I think it’s an Excel version thing. I also
changed “Dim STIPrice” to Variant. Now the program will run past the
“STIPrice = Application.Vlookup …” line but stops farther down where I
try to use STIPrice. It says Run-time erro ‘13’, Type mismatch, and
the little yellow info box that pops up when I put the cursor on it
says STIPrice = Error 2042. Also, the info for the “STIPrice =
Application.Vlookup…” says Error 2042, which I understand is the VBA
equivalent of #N/A. Interestingly, the procedure runs perfectly when
Security doesn’t equal “SunTrust …”. Any ideas?


--

Dave Peterson


 
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
VLookup type mismatch Omar Excel Programming 0 November 24th 06 05:31 PM
Application.Vlookup Type Mismatch Error ssjody[_9_] Excel Programming 2 August 2nd 06 10:24 PM
vlookup type mismatch error Lilivati Excel Programming 3 July 13th 06 08:31 AM
Type mismatch in vlookup carg1[_12_] Excel Programming 5 April 6th 06 11:58 PM
Type Mismatch in Vlookup? LJones[_2_] Excel Programming 1 August 5th 04 07:30 AM


All times are GMT +1. The time now is 02:13 PM.

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

About Us

"It's about Microsoft Excel"