sanjaynaidubas
New Member
- Joined
- Jul 23, 2013
- Messages
- 5
hi,
i have a requirement where i have to format the row based on the input in Column A
also i have to lock few cells of that Row based on the input.
for Example say the Data entered in column 'A' is 'MAIN', then i need to change the color of that row and also lock Cells of C,D and E for that row only.
and say Column C is mandatory, then if user selects another row, without entering the data, alert can pop up asking to fill it.
i have read through forums but none is working
i was able to change the color of the row with is code. but the problem is
the color changes when i re focus the cell 'A' , (after i have Type Main, then i go back to the cell color changes)
where as i wanted, on blur of cell 'A' if data entered is 'MAIN', then change color and lock the cells.
this is what i could figure out from the net.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
RecType = UCase(Target.Text)
Select Case RecType
Case "MAIN"
Range("A" & Target.Row, "H" & Target.Row).Interior.ColorIndex = 10
Case "GR"
Range("A" & Target.Row, "H" & Target.Row).Interior.ColorIndex = 15
End Select
End Sub
Please help!.
thanks in Advance
NOTE : i have to use VBA (Excel versions will vary in this case)
Regards,
Sanjay Naidu
i have a requirement where i have to format the row based on the input in Column A
also i have to lock few cells of that Row based on the input.
for Example say the Data entered in column 'A' is 'MAIN', then i need to change the color of that row and also lock Cells of C,D and E for that row only.
and say Column C is mandatory, then if user selects another row, without entering the data, alert can pop up asking to fill it.
i have read through forums but none is working
i was able to change the color of the row with is code. but the problem is
the color changes when i re focus the cell 'A' , (after i have Type Main, then i go back to the cell color changes)
where as i wanted, on blur of cell 'A' if data entered is 'MAIN', then change color and lock the cells.
this is what i could figure out from the net.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
RecType = UCase(Target.Text)
Select Case RecType
Case "MAIN"
Range("A" & Target.Row, "H" & Target.Row).Interior.ColorIndex = 10
Case "GR"
Range("A" & Target.Row, "H" & Target.Row).Interior.ColorIndex = 15
End Select
End Sub
Please help!.
thanks in Advance
NOTE : i have to use VBA (Excel versions will vary in this case)
Regards,
Sanjay Naidu