Resolved Question: Help with protect/unprotect macros in excel 2003?
I have a spreadsheet I created in excel containing merged cells (it is for an assessment). I need to be able to protect this sheet, and have these merged cells re-size the row height as contents (text) are typed in. I do not want the people who are filling this in able to do anything besides type in the cells I have unlocked, but I need the row height to adjust according to the amount of text they put in the merged cell (yes, unfortunately I had to merge them). I have the macro already that re-sizes row height automatically, but it does not work when I have the sheet protected:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range
With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub
What would I need to do to the macro above in order to have it unprotect the sheet, resize the row height, the re-protect the sheet? I am not at all familiar with VBA, I copied the above macro off another site and it works. Please explain in your answer exactly what I need to do to get this to work. Thanks!
