The below code all seems to work except for the first IF statement (VBA doesn't seem to like the sheet/Range). I think I have to dim sonething as string but dont know how to do it.
Any help please I am on a tight deadline
Sub Sophistication()
' Sophistication Macro
' Sophistion Script is produced for either sophisticated or non sophisticated customers
If Sheets("Sheet1").Range("M17:N17") = None Then
Sheets("Sheet2").Select
Range("D2:R31").Select
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
Selection.ClearContents
With Sheets("Sheet2").Range("D2:R31")
End With
.Value = "“Your case is currently at the sophistication testing phase. I cannot provide you with a precise timeframe as to how long it will take for your case to complete this stage as each case is different. However on average once a case reaches this stage it typically takes X weeks until an outcome is reached. As soon as the outcome is known we will write to you.“"
.Font.Name = "Arial"
.Font.Size = 26
Range("A1").Select
End With
ElseIf Sheets("Sheet1").Range("AB16") = 1 Then
Sheets("Sheet2").Select
Range("D2:R31").Select
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
Selection.ClearContents
With Sheets("Sheet2").Range("D9:R26")
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 (Date) to advise you of this and to ask whether you wanted to provide further information" & vbNewLine _
& "Have you received this letter?"
.Font.Name = "Arial"
.Font.Size = 26
Range("A1").Select
End With
ElseIf Sheets("Sheet1").Range("AB17") = 1 Then
Sheets("Sheet2").Select
Range("D2:R31").Select
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
Selection.ClearContents
With Sheets("Sheet2").Range("D9:R26")
End With
.Value = "Your case has been deemed Non-Sophisticated which means you are in scope of the review." & vbNewLine _
& vbNewLine _
& "We wrote to you on (Date) to advise you of this and to ask whether you wanted to provide further information" & vbNewLine _
& "Have you received this letter?"
.Font.Name = "Arial"
.Font.Size = 26
Range("A1").Select
End With
End If
End Sub
Bookmarks