You're on the right track. You just have a few things out of place. Also, I would recommend changing the name of your sub. Some might mistake it for the Initialize event of a form since it is so close. Another thing you might want to do is to name the range B19:B23. If a user adds in new rows or deletes rows, those may not be the rows you want to reference anymore. By naming the range, the name will move to wherever the cells move to. To name the range, just select the cells then go to the Name Box above cell A1 and type in a name then press Enter.
The main reason your code isn't working is because you have your if statements starting before your For/Next statements. They should be more like this:
For Each cell In hidden1923
If cell.EntireRow.Hidden = true Then
EntireRow.Hidden = false
End If
Next
For Each cell In hidden1923
If cell.EntireRow.Hidden = False Then
EntireRow.Hidden = True
End If
Next
Another thing I want to mention is that you don't need the Select statement in your code. That doesn't do anything to help hide or unhid the cells.
Another big reason your code isn't working is because you have TWO IF statements and TWO FOR/NEXT statements. Basically when the 2nd For/Next statement runs, it would undo everything that your first For/Next statement did. So you need to combine that into ONE For/Next loop and to use and ElseIf statement for the ones that are not hidden to hide them. Oh yeah, and you need to declare a variable for hidden1923. You should declare it as a Range object. So basically here's how you'd want your code to look when it's all said and done:
Sub HideMyRows()
Dim hidden1923 As Range
Dim x As Range
'Name range B19:B23 as MyHiddenRows
Set hidden1923 = Range("MyHiddenRows")
For Each x In hidden1923
If x.EntireRow.Hidden = True Then
x.EntireRow.Hidden = False
ElseIf x.EntireRow.Hidden = False Then
x.EntireRow.Hidden = True
End If
Next x
End Sub
Also when you declare Next you have to put something after the Next. The way you had it written you would have needed to put "Next cell". I believe you also could have written your code like this and it would have worked:
Sub HideMyRows()
Dim hidden1923 As Range
'Name range B19:B23 as MyHiddenRows
Set hidden1923 = Range("MyHiddenRows")
For Each cell In hidden1923
If cell.EntireRow.Hidden = True Then
cell.EntireRow.Hidden = False
ElseIf cell.EntireRow.Hidden = False Then
cell.EntireRow.Hidden = True
End If
Next cell
End Sub
I'm not one to kind of just GIVE the person the answer. I'm more one where I like to teach them the right way to do it and WHY.