Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default I Know I'm Missing Something...but what?

I have the following lines of code running as a Private Function within my macro:

Private Function DetermineColumn(cell As Range) As Long
Dim sAttachmentType As String
Dim sAttachmentColor As String
Dim sAttachmentSize As String
sAttachmentType = LCase(cell(1, 11).Value)
sAttachmentColor = LCase(cell(1, 12).Value)
sAttachmentSize = Trim(cell(1, 13).Text)
DetermineColumn = 0

If sAttachmentType = "steel angle" Then
Select Case sAttachmentColor
Case "white"
If sAttachmentSize = "15/16" Then
DetermineColumn = 5
ElseIf sAttachmentSize = "9/16" Then
DetermineColumn = 7
Else
DetermineColumn = 0
End If

Case "bronze"
DetermineColumn = 9
Case "wood"
DetermineColumn = 11
Case "black"
DetermineColumn = 13
Case "paint"
DetermineColumn = 15
End Select

ElseIf sAttachmentType = "steel tape" Then
Select Case sAttachmentColor
Case "white"
DetermineColumn = 17
Case "paint"
DetermineColumn = 19
End Select
End If

End Function

I added the following If statement to the code

If sAttachmentType = "steel angle" Then
Select Case sAttachmentColor
Case "white"
If sAttachmentSize = "15/16" Then
DetermineColumn = 5
ElseIf sAttachmentSize = "9/16" Then
DetermineColumn = 7
Else
DetermineColumn = 0
End If

Case "bronze"
DetermineColumn = 9
Case "wood"
DetermineColumn = 11
Case "black"
DetermineColumn = 13
Case "paint"
DetermineColumn = 15
End Select

ElseIf sAttachmentType = "Inside Angle" Then
Select Case sAttachmentColor
Case "White"
DetermineColumn = 17
Case "Paint"
DetermineColumn = 19
End Select


ElseIf sAttachmentType = "steel tape" Then
Select Case sAttachmentColor
Case "white"
DetermineColumn = 21
Case "paint"
DetermineColumn = 23
End Select
End If

End Function

When I run the macro it skips right over the new ElseIf statement and acts as though it isn't there. I recieve no errors and no result data if "Inside Angle" is chosen as my sAttachmentType. If "Steel Angle" or "Steel Tape" is chosen as my sAttachment Type then the result data is calculated correctly.

Any ideas? I'm sure it's something simple but I haven't been able to see it.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default I Know I'm Missing Something...but what?

A logical approach would be to do

sAttachmenttype = lcase( something).

if that is the case, then this can never be true

sAttachmentType = "Inside Angle"


you might alter your test to

sAttachmentType = "inside angle"


--
Regards,
Tom Ogilvy


"GreenMonster" wrote in message
...
I have the following lines of code running as a Private Function within my
macro:

Private Function DetermineColumn(cell As Range) As Long
Dim sAttachmentType As String
Dim sAttachmentColor As String
Dim sAttachmentSize As String
sAttachmentType = LCase(cell(1, 11).Value)
sAttachmentColor = LCase(cell(1, 12).Value)
sAttachmentSize = Trim(cell(1, 13).Text)
DetermineColumn = 0

If sAttachmentType = "steel angle" Then
Select Case sAttachmentColor
Case "white"
If sAttachmentSize = "15/16" Then
DetermineColumn = 5
ElseIf sAttachmentSize = "9/16" Then
DetermineColumn = 7
Else
DetermineColumn = 0
End If

Case "bronze"
DetermineColumn = 9
Case "wood"
DetermineColumn = 11
Case "black"
DetermineColumn = 13
Case "paint"
DetermineColumn = 15
End Select

ElseIf sAttachmentType = "steel tape" Then
Select Case sAttachmentColor
Case "white"
DetermineColumn = 17
Case "paint"
DetermineColumn = 19
End Select
End If

End Function

I added the following If statement to the code

If sAttachmentType = "steel angle" Then
Select Case sAttachmentColor
Case "white"
If sAttachmentSize = "15/16" Then
DetermineColumn = 5
ElseIf sAttachmentSize = "9/16" Then
DetermineColumn = 7
Else
DetermineColumn = 0
End If

Case "bronze"
DetermineColumn = 9
Case "wood"
DetermineColumn = 11
Case "black"
DetermineColumn = 13
Case "paint"
DetermineColumn = 15
End Select

ElseIf sAttachmentType = "Inside Angle" Then
Select Case sAttachmentColor
Case "White"
DetermineColumn = 17
Case "Paint"
DetermineColumn = 19
End Select


ElseIf sAttachmentType = "steel tape" Then
Select Case sAttachmentColor
Case "white"
DetermineColumn = 21
Case "paint"
DetermineColumn = 23
End Select
End If

End Function

When I run the macro it skips right over the new ElseIf statement and acts
as though it isn't there. I recieve no errors and no result data if "Inside
Angle" is chosen as my sAttachmentType. If "Steel Angle" or "Steel Tape" is
chosen as my sAttachment Type then the result data is calculated correctly.

Any ideas? I'm sure it's something simple but I haven't been able to see
it.



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
What am I missing? Scoober Excel Discussion (Misc queries) 4 February 16th 09 07:54 PM
#missing! Arne Hegefors Excel Worksheet Functions 2 October 15th 08 05:50 PM
Toolbars Missing, And option to Add Missing SmeetaG Excel Discussion (Misc queries) 3 October 19th 05 11:43 AM
What am I missing here....? swatsp0p[_2_] Excel Programming 3 February 16th 05 01:59 PM
Missing Row Debbie Humphrey Excel Worksheet Functions 3 January 12th 05 06:26 PM


All times are GMT +1. The time now is 03:52 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"