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
Bookmarks