Just wondering if anyone had, I am guessing 5 mins to help me out with something that is probably very obvious (but not to me - at the moment)
Essentially I have a template spreadsheet with months in columns and departments in rows. Rows per department will be consistent throughout but will vary between departments. I have written code that will prevent overtyping previous month / future month data, and also to ensure each department can only enter data for their department. Individually both sets of code run.
However, what I need to do is amend the code so that rows and columns will both be blocked except for those that intersect each other - and that is where I have broken it.
Just wondering if someone could take a peek at my attempt, and when you've finished laughing point me in the right direction.
Sub columnlock() Dim mycell As Range Dim strPassword As String Dim x As String Dim Value As Range Sheet1.Select ActiveSheet.Unprotect Password:="hello" Sheet2.Visible = xlSheetHidden Cells.Locked = False For Each Value In Range("M2:AJ2").Cells If Value <> "TT" Then Value.EntireColumn.Locked = True End If Next For Each Value In Range("A40:A120").Cells If Value <> "TT" Then Value.EntireRow.Locked = True End If Next Sheet2.Visible = xlSheetVeryHidden ActiveSheet.Protect Password:="hello"
From the error messages I think it doesn't like the 2 lots of "for each"
Any help is appreciated.