Not sure what the specialcells is all about, but maybe it should be
Private Sub CommandButton1_Click()
 Dim pass As String
 pass = "nh1234"
 ActiveSheet.Protect Password:=pass, UserInterFaceOnly:=True


 With Range("A17:A42").SpecialCells(xlVisible).Areas(1)
 
     .Offset(.Count).Resize(1).EntireRow.Hidden = False
 End With

 Cells(Rows.Count, "A").End(xlUp).EntireRow.Select 
End Sub