PC Review


Reply
Thread Tools Rate Thread

Case Else problem with #VALUE appearing in cells

 
 
=?Utf-8?B?TWVtZW50bw==?=
Guest
Posts: n/a
 
      30th May 2007
Hello Guys,

I have the following function procedure:

Function TotalCode(ByVal vCode As String, ByVal VB As Single, ByVal CAD As
Single, ByVal hours As Single, ByVal Roster As Single, ByVal ADVUren As
Single) As Single
Dim CodeNormal, CodePlus, CodeIll
CodeNormal = Array("ADV", "ANC", "CP", "EDUC", "ELF", "FAM", "FD", "JV",
"KV", "OA", "SOL", "ST", "SV", "TA", "TK", "V35", "VB", "VC", "VFD", "ZZ")
CodePlus = Array("ADV+", "ANC+", "CP+", "OA+", "SOL+", "SV+", "TK+", "V35+",
"VB+", "VC+", "Z+")
CodeIll = Array("AO", "Z")
Select Case vCode
Case cNormal
If vCode = CodeNormal Then
TotalCode = VB + ADVUren + CAD
End If
Case cPlus
If vCode = CodePlus Then
TotalCode = Rooster + ADVUren + CAD
End If
Case cIll
If vCode = CodeIll Then
TotalCode = Rooster + VB + ADVUren + uren + CAD
End If
Case Else
TotalCode = Rooster + VB + ADVUren + CAD
End Select
End Function

So I start using the function as a formula into a cell (=TotalCode(A1; B1;
C1...)

The problem seems to arise here:
If vCode = CodeNormal Then
TotalCode = VB + ADVUren + CAD
End If

When vCode is not filled in, the formula keeps giving me #VALUE! into the
cell. If I get rid of the arrays, and use the codes itself (example):

If vCode = ADV then
TotalCode = VB + ADVUren + CAD
End If

It seems to work okay.

Any suggestions to get rid of the #VALUE! in the cell when nothing is filled
in?

Thanks in advance guys!

With kind regards,

Memento
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      30th May 2007
Function TotalCode(ByVal vCode As String, ByVal VB As Single, _
ByVal CAD As Single, ByVal hours As Single, _
ByVal Roster As Single, ByVal ADVUren As Single) _
As Single
Dim CodeNormal, CodePlus, CodeIll
CodeNormal = Array("ADV", "ANC", "CP", "EDUC", "ELF", "FAM", "FD", "JV", _
"KV", "OA", "SOL", "ST", "SV", "TA", "TK", "V35", _
"VB", "VC", "VFD", "ZZ")
CodePlus = Array("ADV+", "ANC+", "CP+", "OA+", "SOL+", "SV+", "TK+", _
"V35+", "VB+", "VC+", "Z+")
CodeIll = Array("AO", "Z")
Select Case vCode
Case cNormal
If Not IsError(Match(vCode, CodeNormal, 0)) Then
TotalCode = VB + ADVUren + CAD
End If
Case cPlus
If Not IsError(Match(vCode, CodePlus, 0)) Then
TotalCode = Rooster + ADVUren + CAD
End If
Case cIll
If Not IsError(Match(vCode, CodeIll, 0)) Then
TotalCode = Rooster + VB + ADVUren + uren + CAD
End If
Case Else
TotalCode = Rooster + VB + ADVUren + CAD
End Select
End Function

What is cNormal, cPlus etc.?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Memento" <(E-Mail Removed)> wrote in message
news:2AD93AA2-2789-450A-BBF4-(E-Mail Removed)...
> Hello Guys,
>
> I have the following function procedure:
>
> Function TotalCode(ByVal vCode As String, ByVal VB As Single, ByVal CAD As
> Single, ByVal hours As Single, ByVal Roster As Single, ByVal ADVUren As
> Single) As Single
> Dim CodeNormal, CodePlus, CodeIll
> CodeNormal = Array("ADV", "ANC", "CP", "EDUC", "ELF", "FAM", "FD", "JV",
> "KV", "OA", "SOL", "ST", "SV", "TA", "TK", "V35", "VB", "VC", "VFD", "ZZ")
> CodePlus = Array("ADV+", "ANC+", "CP+", "OA+", "SOL+", "SV+", "TK+",
> "V35+",
> "VB+", "VC+", "Z+")
> CodeIll = Array("AO", "Z")
> Select Case vCode
> Case cNormal
> If vCode = CodeNormal Then
> TotalCode = VB + ADVUren + CAD
> End If
> Case cPlus
> If vCode = CodePlus Then
> TotalCode = Rooster + ADVUren + CAD
> End If
> Case cIll
> If vCode = CodeIll Then
> TotalCode = Rooster + VB + ADVUren + uren + CAD
> End If
> Case Else
> TotalCode = Rooster + VB + ADVUren + CAD
> End Select
> End Function
>
> So I start using the function as a formula into a cell (=TotalCode(A1; B1;
> C1...)
>
> The problem seems to arise here:
> If vCode = CodeNormal Then
> TotalCode = VB + ADVUren + CAD
> End If
>
> When vCode is not filled in, the formula keeps giving me #VALUE! into the
> cell. If I get rid of the arrays, and use the codes itself (example):
>
> If vCode = ADV then
> TotalCode = VB + ADVUren + CAD
> End If
>
> It seems to work okay.
>
> Any suggestions to get rid of the #VALUE! in the cell when nothing is
> filled
> in?
>
> Thanks in advance guys!
>
> With kind regards,
>
> Memento



 
Reply With Quote
 
=?Utf-8?B?TWVtZW50bw==?=
Guest
Posts: n/a
 
      30th May 2007
Hello Bob,

Thanks for your solution, however: i've managed to narrow this down quite a
bit. I noticed I shouldn't use arrays for this simple purpose. So I used the
following, with success (the #VALUE! is also gone with this, since this gets
caught by the Case Else instruction).

Thanks anyway.

Function Total(ByVal vCode As String, ByVal VB As Single, ByVal CAD As
Single, ByVal hours As Single, ByVal Rooster As Single, ByVal ADVUren As
Single) As Single
Select Case vCode
Case "ADV" To "ZZ"
Totaal = VB + ADVUren + CAD
Case "ADV+" To "Z+"
Totaal = Rooster + ADVUren + CAD
Case "AO", "Z"
Totaal = Rooster + VB + ADVUren + hours + CAD
Case Else
Totaal = Rooster + VB + ADVUren + CAD
End Select
End Function


"Memento" wrote:

> Hello Guys,
>
> I have the following function procedure:
>
> Function TotalCode(ByVal vCode As String, ByVal VB As Single, ByVal CAD As
> Single, ByVal hours As Single, ByVal Roster As Single, ByVal ADVUren As
> Single) As Single
> Dim CodeNormal, CodePlus, CodeIll
> CodeNormal = Array("ADV", "ANC", "CP", "EDUC", "ELF", "FAM", "FD", "JV",
> "KV", "OA", "SOL", "ST", "SV", "TA", "TK", "V35", "VB", "VC", "VFD", "ZZ")
> CodePlus = Array("ADV+", "ANC+", "CP+", "OA+", "SOL+", "SV+", "TK+", "V35+",
> "VB+", "VC+", "Z+")
> CodeIll = Array("AO", "Z")
> Select Case vCode
> Case cNormal
> If vCode = CodeNormal Then
> TotalCode = VB + ADVUren + CAD
> End If
> Case cPlus
> If vCode = CodePlus Then
> TotalCode = Rooster + ADVUren + CAD
> End If
> Case cIll
> If vCode = CodeIll Then
> TotalCode = Rooster + VB + ADVUren + uren + CAD
> End If
> Case Else
> TotalCode = Rooster + VB + ADVUren + CAD
> End Select
> End Function
>
> So I start using the function as a formula into a cell (=TotalCode(A1; B1;
> C1...)
>
> The problem seems to arise here:
> If vCode = CodeNormal Then
> TotalCode = VB + ADVUren + CAD
> End If
>
> When vCode is not filled in, the formula keeps giving me #VALUE! into the
> cell. If I get rid of the arrays, and use the codes itself (example):
>
> If vCode = ADV then
> TotalCode = VB + ADVUren + CAD
> End If
>
> It seems to work okay.
>
> Any suggestions to get rid of the #VALUE! in the cell when nothing is filled
> in?
>
> Thanks in advance guys!
>
> With kind regards,
>
> Memento

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
translate VB select case to switch case problem Rich P Microsoft C# .NET 13 8th Aug 2009 06:07 PM
Case without Select Case error problem Ayo Microsoft Excel Misc 2 16th May 2008 03:48 PM
How to change mixed case to upper case in Excel for all cells =?Utf-8?B?V29yZEFsb25lIE5ldHdvcms=?= Microsoft Excel Misc 7 30th May 2007 05:53 AM
Frame is not appearing using select case =?Utf-8?B?RW1tYQ==?= Microsoft Access Form Coding 1 14th Jun 2006 12:20 AM
Cells(col,row) keep moving to lower case and I can not ref. a cells in a differnet sheet WayneL Microsoft Excel Programming 2 25th Apr 2005 11:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:28 AM.