Hello,
This is no biggie here - really just wondering if there is a more efficient way to code this (my programming skills are very limited to say the least).
I have three routines that basically do the same thing to three sets of cells. I simply copied the code from the first set; then edit it for the next two. It appears to be doing what I want. However, I suspect there is a better way to achieve this.
I don’t expect anyone to spend much time on this but if it looks easy enough to clean up, I would be interested.
Here’s my code –
Thanks for viewing,
Steve
This is no biggie here - really just wondering if there is a more efficient way to code this (my programming skills are very limited to say the least).
I have three routines that basically do the same thing to three sets of cells. I simply copied the code from the first set; then edit it for the next two. It appears to be doing what I want. However, I suspect there is a better way to achieve this.
I don’t expect anyone to spend much time on this but if it looks easy enough to clean up, I would be interested.
Here’s my code –
VBA Code:
‘- - - 1st One-Time - - -
If Range("K8:K9").Locked = False And Range("K9") = "" Then
MsgBox " Missing One-Time Amount" & vbNewLine & " Re-enter Payment details.", , " One-Time Pmt."
Range("K8,K9").Select
Selection.ClearContents
Range("K9").Select
Selection.Locked = True
With Selection.Interior
.Color = 15984868
End With
Range("K8").Select
Exit Sub
End If
‘- - - 2nd One-Time - - -
If Range("K10:K11").Locked = False And Range("K11") = "" Then
MsgBox " Missing One-Time Amount" & vbNewLine & " Re-enter Payment details.", , " One-Time Pmt."
Range("K10,K11").Select
Selection.ClearContents
Range("K11").Select
Selection.Locked = True
With Selection.Interior
.Color = 15984868
End With
Range("K10").Select
Exit Sub
End If
‘- - - 3rd One-Time - - -
If Range("K12:K13").Locked = False And Range("K13") = "" Then
MsgBox " Missing One-Time Amount" & vbNewLine & " Re-enter Payment details.", , " One-Time Pmt."
Range("K12,K13").Select
Selection.ClearContents
Range("K13").Select
Selection.Locked = True
With Selection.Interior
.Color = 15984868
End With
Range("K12").Select
Exit Sub
End If
Thanks for viewing,
Steve