Link to home
Start Free TrialLog in
Avatar of Frank Freese
Frank FreeseFlag for United States of America

asked on

An easier way to write this sub-routine

Folks,
Examine the code below. I have 14 of these to do they way I am doing it. If this is the best way, OK. If not, I'd like to reduce the amount of code. My range is from C9:C23 and D9:D23:
 If Range("C9").Text = "FALSE" Then
        Range("D9").Locked = False
        Range("D9").Font.Color = vbWhite
        Range("D9").Interior.Color = vbRed
        Range("D9").Value = "Correct"
    Else
        Range("D9").Value = "Error"
        Range("D9").Font.Color = vbYellow
        Range("D9").Interior.Color = vbBlack
        Range("D9").Locked = True
        CheckFormulaFunction
        Exit Sub
    End If
    
     If Range("C10").Text = "FALSE" Then
        Range("D10").Locked = False
        Range("D10").Font.Color = vbWhite
        Range("D10").Interior.Color = vbRed
        Range("D10").Value = "Correct"
    Else
        Range("D10").Value = "Error"
        Range("D10").Font.Color = vbYellow
        Range("D10").Interior.Color = vbBlack
        Range("D10").Locked = True
        CheckFormulaFunction
        Exit Sub
    End If
    
     If Range("C11").Text = "FALSE" Then
        Range("D11").Locked = False
        Range("D11").Font.Color = vbWhite
        Range("D11").Interior.Color = vbRed
        Range("D11").Value = "Correct"
    Else
        Range("D11").Value = "Error"
        Range("D11").Font.Color = vbYellow
        Range("D11").Interior.Color = vbBlack
        Range("D11").Locked = True
        CheckFormulaFunction
        Exit Sub
    End If

Open in new window

SOLUTION
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Frank Freese

ASKER

WOW - looks like two great solutions with different approaches.
If I have a problem I'll follow up
Thank you very much.
Thanks for the grade, but I think your mouse slipped when you accepted only my solution, especially since you als315's was first and mine was very similar (such that I wouldn't have posted it, if I had seen his first).

If you agree, please follow the Request Attention link and ask for the question to be reopened so you give all or some of the credit where it's due.

Thanks,

Thomas
You're absolutely correct - not by design. Now where is the Request Attention link (I'm looking)?
I found it!
I just asked to correct my mistake. I'm truly sorry for the error and I appreciate you bringing it to my attention.
Thomas,
Let me know if you do not get your points.
Frank