Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
What am I missing? | Excel Discussion (Misc queries) | |||
#missing! | Excel Worksheet Functions | |||
Toolbars Missing, And option to Add Missing | Excel Discussion (Misc queries) | |||
What am I missing here....? | Excel Programming | |||
Missing Row | Excel Worksheet Functions |