LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Comparing a range of values against a cell

Hello Guys,

This code kills me at the moment. I've already realized that working with
ranges etc, can be quite cumbersome and tricky:

Function VBCode(vCode As String, Jobtime As Single, Roster As Single) As
Single
Dim cell As Variant
Set cRange = Worksheets("CODE").range("CodeNorm")
For Each cell In cRange
If cell = vCode Then
VBCode = Jobtime / 5
Else
VBCode = ""
End If
Next cell
End Function

The range "CodeNorm" are just short strings.

The crazy thing is that when i use this function in a cell, it keeps giving
me a "a value in the cell has a incorrect datatype". When i put a breakpoint
at "If cell = vCode then", I can see they all contain the actual string
values I need for this to work. So i'm kinda lost here, I don't know why this
doesn't work as it needs to be...

Anyone can easily recreate this by creating some string items like "ADV,
TOP, BUJ", etc... in a few adjacent cells, make it a named range "CodeNorm",
create the above function in a module, and try the function in a cell.

Anyone knows why this doesn't work?

Thanks in advance guys.

Memento

 
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
Comparing a range of values tamirh Excel Discussion (Misc queries) 3 November 7th 08 10:51 PM
Comparing a Range of Values jpx Excel Discussion (Misc queries) 4 November 22nd 05 10:28 PM
Comparing cell values Touk Excel Programming 3 September 29th 04 11:04 AM
Comparing Values in Range M Todd Huttenstine[_2_] Excel Programming 0 December 1st 03 08:35 PM
Comparing Values in Range M Todd Huttenstine[_2_] Excel Programming 1 December 1st 03 02:22 PM


All times are GMT +1. The time now is 07:17 AM.

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"