karthik537
New Member
- Joined
- Jul 30, 2011
- Messages
- 8
Hi Friends,
I have 2 columns (Column A and Column B), in which Column A is a dropdown list(FR, Query, Others). In Column A, for a particular cell(for eg: A2), if I select either "FR" or "Query", the respecive row(For Eg:B2) in Column B should be disabled. I have the following code.
But the above vb script is running only for one time. Let us say for first time if I select cell A2 and have chosen the value "FR" from list, the cell B2 is disabled but if I select another cell in Column A (For eg: A3) in which I selected "FR" in drop down list, I am getting "Run Time Error 1004"...( but the B3 cell is not being disabled in Column B)
Please help me..
I have 2 columns (Column A and Column B), in which Column A is a dropdown list(FR, Query, Others). In Column A, for a particular cell(for eg: A2), if I select either "FR" or "Query", the respecive row(For Eg:B2) in Column B should be disabled. I have the following code.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ColLtr As String, RowNo As Integer
RowNo = ActiveCell.Row
ColLtr = "B"
If Target.Address = "$A$" & RowNo Then
If Target.Value = "FR" Or Target.Value = "Query" Then
Range(ColLtr & RowNo).Interior.Color = RGB(192, 192, 192)
ActiveSheet.Cells.Locked = False
Range(ColLtr & RowNo).Locked = True
ActiveSheet.Protect
Else
ActiveSheet.Unprotect
Range(ColLtr & RowNo).Interior.ColorIndex = xlNone
End If
End If
End Sub
But the above vb script is running only for one time. Let us say for first time if I select cell A2 and have chosen the value "FR" from list, the cell B2 is disabled but if I select another cell in Column A (For eg: A3) in which I selected "FR" in drop down list, I am getting "Run Time Error 1004"...( but the B3 cell is not being disabled in Column B)
Please help me..
Last edited: