Unable to set the locked propert

B

bsherwood

Hi,

I have a number of combo boxes in a worksheet. Depending on the
entries of these combo boxes certain cells may be locked. The list
fill range for these combo boxes are taken from cells that are linked
to an external(web) query. Whenever I refresh these linked cells excel
calls the combo box change() procedure. When this happens I get the
error message

"Run-time error '1004' Unable to set the locked property o fthe range
class"

All of my combo boxes call the following procedure when they are
called


Code:
--------------------


Sub cmbLoc_Change(row As Integer, sheet As String, chkValue As Boolean)

Application.ScreenUpdating = False

Dim origin As Integer
Dim dest As Integer
Dim cmbRow As Integer
Dim testBool As Boolean

origin = isRiseLocation(ThisWorkbook.Worksheets(sheet).Cells(row, 29))
dest = isRiseLocation(ThisWorkbook.Worksheets(sheet).Cells(row, 30))
'isRiseLocation provides 0 if it is not a rise location otherwise it provides
' a number related to a specific rise location


If (origin > 0 And dest > 0) Then
ThisWorkbook.Worksheets(sheet).Cells(row, 8) = 0
If (chkValue = True) Then
ThisWorkbook.Worksheets(sheet).Cells(row, 9) = 2 * ThisWorkbook.Worksheets("miles").Cells(origin, dest)
Else
ThisWorkbook.Worksheets(sheet).Cells(row, 9) = ThisWorkbook.Worksheets("miles").Cells(origin, dest)
End If
ThisWorkbook.Worksheets(sheet).Cells(row, 8).Locked = True
ThisWorkbook.Worksheets(sheet).Cells(row, 9).Locked = True
'2 lines above causes errors
Else
ThisWorkbook.Worksheets(sheet).Cells(row, 8).Locked = False
ThisWorkbook.Worksheets(sheet).Cells(row, 9).Locked = False
'2 lines above causes errors
End If


Application.ScreenUpdating = True

End Sub

--------------------


Currently my sheets are not protected, I unprotected everything while
trying to troubleshoot this problem. The cells I am trying to lock are
not merged. I only get an error when doing a refresh of the external
errors. If I change the values in the combo box directly, it works
fine.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top