locking specific cells that are hidden/shown based on VBA

Excell-ent

New Member
Joined
Jan 13, 2014
Messages
1
Hello!
I am completely new to VBA, however am trying to learn as much as possible and could really do with some help here!

I am having trouble with my VBA code, it hides groups of rows (projects) based on the contents of corresponding cells above. these have either 'yes' or 'no' in them (indicating if the person is active in that project). The Yes/No is formula based from another sheet.

what I am trying to do, is have particular cells, withing the projects rows, locked (as they are also populated by formulas) but have other cells open for editing.

when I try and do this i get an error with my VBA, i am assuming that as cells are locked, the VBA is prohibited form hiding inactive projects/rows.
i tried an addition at the bottom but this hasn't worked

Code:
Sub Worksheet_Calculate()
    Dim i As Long, StartRow As Long, EndRow As Long

StartRow = 13
EndRow = 29

For i = 6 To 11
    If UCase(Range("C" & i).Value) = "NO" Then
        Rows(StartRow & ":" & EndRow).EntireRow.Hidden = True
    Else
        Rows(StartRow & ":" & EndRow).EntireRow.Hidden = False
    End If
    StartRow = StartRow + 18
    EndRow = EndRow + 18
    Next i

End Sub

Private Sub Workbook_Open()
Sheets("Sheet1").Protect Password:="password", UserInterFaceOnly:=True
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hello and welcome to the Forum. I am not well versed in the way of the VBA either.... but I do know that when you protect a sheet using ALT+T,P,P that you are then unable to accomplish a wide number of things to the sheet even to the unprotected cells. because the entire sheet is locked. hopefully someone else can weigh in on your Code. again welcome to the board.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top