Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I lock or grey out a cell?

Status
Not open for further replies.

mimitan

Technical User
Dec 17, 2004
34
Hi everyone

I have 2 columns A and B (A progid, B Qty)as follow:

Progid Qty
Asid
Hgid
Bhid
c grey out
whid
Anid
c grey out
Gtid
and so on...

I am trying to set up the Qty column with cell grey out when Progid is blank so that user can not enter data in these cells in a macro.
Appreciate your helps
 
I assumed there is no value where it says "c grey out"

This may not be the best way to write the code, but it was based with the information I had.


Code:
Sub Macro1()

ActiveSheet.Unprotect "password"
Range("A1").Select
    Do Until ActiveCell.Address(False, False) = "A65536"
    
    ActiveCell.End(xlDown).Select
    If ActiveCell.Address(False, False) = "A65536" Then
    Else
    ActiveCell.Offset(1, 0).Select
    ActiveCell.EntireRow.Select
    Selection.Locked = True
    With Selection.Interior
        .ColorIndex = 15
        .Pattern = xlSolid
    End With
    
    ActiveCell.Offset(1, 0).Select
    End If
    Loop
    ActiveSheet.Protect "password"
    Range("a1").Select
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top