Results 1 to 10 of 10

Code not producing a value

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    640

    Code not producing a value

    I have copied and pasted this code across from somewhere where the If statement is based on cell values so I know it works. Now it is based on userform values and refuses to produce anything.

    Mtt_Script = Userform
    UoW = Combobox 1
    Letter = Combobox 2
    Sophistciated refers to a Select case range

    Select Case ComboBox1
        Case 231, 232, 233, 234, 235, 236
             Letter = "Sophisticated"
        Case 221, 222, 228, 229, 237
             Letter = "Unsophisticated"
    End Select

    It must have something to do with the If statement but I have also copied each criteria from elsewhere in the code where it works and I cannot for the life of me work out why it does not work in this one instance. I cannot see the same two cells referenced in this way elsewhere in the code so it can't be ambigious coding.

    Please, please, please can someone show me the very simple thing I am doing wrong (it's always something simple that catches me out)????????


    ' Sophisticated Letter & Sophistication Test UoW

     If MTT_Script.UoW = "Sophistication Test" And MTT_Script.Letter = "Sophisticated" Then
            Sheets("Sheet2").Select
            Range("D2:S32").Select
            Selection.ClearContents
            Selection.Font.Underline = xlUnderlineStyleNone
            Selection.Font.ColorIndex = 0
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .MergeCells = True
            .WrapText = True
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlMedium
            .ColorIndex = xlAutomatic
        End With
        Selection.Borders(xlInsideVertical).LineStyle = xlNone
        Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        With Sheets("Sheet2").Range("D2:S32")
        End With
            .Value = "“Your case has been deemed Sophisticated which means you are not in scope of the review.“" & vbNewLine & _
            vbNewLine & _
            "“We wrote to you on " & Sheets("Sheet1").Range("P20") & " to advise you of this and to ask whether you wanted to provide further information“" & vbNewLine & _
            vbNewLine & _
            "“Have you received this letter?“" & vbNewLine & _
            "If No - Select the Unreceived Letters Button."
            .Font.Name = "Arial"
            .Font.Size = 22
            Range("A1").Select
        End With
    Userform is attached
    Attached Files Attached Files
    Last edited by Sc0tt1e; 11-29-2013 at 12:11 PM. Reason: Drop downs on attachment had no values

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I need a code for presence check to check multiple text boxes and combo boxes
    By Lee_wwfc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2013, 01:53 PM
  2. [SOLVED] Vba code to fill check in & check out counts
    By ashfaquebwd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2013, 09:02 AM
  3. [SOLVED] vba code to be correct and check ,vba code to brig data for the same refreince
    By funtastic in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-25-2012, 02:29 PM
  4. check my code - big ask
    By Little pete in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2005, 02:05 PM
  5. [SOLVED] Just a code check please...
    By ste mac in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-21-2005, 06:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1