Reputation: 237
I want to disable a cell if another call contains certain values, i have written the below piece of code but it is throwing me an error
"Wrong number of argument or invalid property assignment".
Kindly help me to resolve this issue.
Private Sub ComboBox1_Click()
Dim projworkbook As Workbook
Dim page1 As Worksheet
Set projworkbook = ActiveWorkbook
Set page1 = projworkbook.Worksheets("Project_Creation")
If Me.ComboBox1.Text = "Extention" Then
Me.ComboBox2.Visible = True else
page1.Range("B5").AllowEdit = False '-> I am getting error here
end if
End Sub
Upvotes: 1
Views: 629
Reputation: 57683
The issue is that .AllowEdit
is read only, so you cannot set it to False
.
Instead use .Locked = True
to lock a range, or accordingly .Locked = False
to unlock a range.
Note that the worksheet needs to be protected so that this property is used. By default all ranges are marked as .Locked = True
so if you protect a sheet everything gets locked. So you probably need to unlock the ranges you don't want to be locked when you protect the sheet.
Upvotes: 1