OK guys, I have a bigger problem...after fixing the read only cell
issue as described by Ken, excel hangs as I have another function -
Private Sub Worksheet_Change(ByVal Target As Range)
This function is called by Worksheet_SelectionChange....why? And this
function is doing some sort of loop over 64k rows and 25 columns, which
basically hangs excel.
Please help....
The code is pasted below:
===============================================================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Selection, Range("N5
5")) Is Nothing Then
Range("A5").Select
End If
End Sub
===============================================================
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Col As Integer, ColLimit As Integer, ctcol As Integer, ctrow As
Integer
Dim Row As Double, RowLimit As Double
Dim StopCol As Integer, StopRow As Integer
Dim strlc As String
Dim whichRow As Integer, whichCol As Integer
whichRow = Target.Row
whichCol = Target.Column
RowLimit = 65536 'Maximun number of rows allowed in a sheet
ColLimit = 25 'Maximun number of columns allowed in a sheet
'Find the data columns and first data row
Row = 1 'Set row counter to row 1
Col = 1 'Set column counter to
column 1
Do While Row < RowLimit
ctrow = LTrim(Str(Row)) 'Set row index loop
Do While Col < ColLimit
ctcol = LTrim(Str(Col)) 'Set column index loop
test = Cells(ctrow, ctcol).Text 'Read the value of the cell
and store into test
Select Case test 'Evaluate test to set event
area
Case "DIB"
StopCol = Col 'Set StopCol to the current
column
StartRow = Row + 1 'Set StartRow to the current
row + 1
Col = ColLimit
Row = RowLimit
Case Else
Col = Col + 1 'Increment the column
index to move to the next cell
End Select
Loop
Col = 1
Row = Row + 1
Loop
If Target.Row < StartRow Then Exit Sub
If Target.Column >= StopCol Then Exit Sub
If Target.Columns.Count >= ColLimit Then Exit Sub
'Clear the "DIB" column
StopRow = Target.Rows.Count - 1
Range(Cells(Target.Row, StopCol), Cells(Target.Row + StopRow, StopCol +
2)).ClearContents
End Sub
===============================================================