Macro to select Range to protect and unprotect ranges

J

jambun

I use the following macros to go from Day 1 window to Day 2 window on
the same sheet and to enable me to tab only on each "window" which is
visable I have locked the cells on day 1 when I work in Day 2 so as
not to tab inadvertantly back on day 1(All the cells between these
sheets contain formulas which are locked. I have had to split the
setranges as Exel dose not want to accept a longer set of ranges.
All seems to work at this stage, exept when I go back to Day 1 where
the last range selected is still selected and i have to click on a
cell to unselect. Is there a command to insert in this code so that
when I go to day 1 there is no selection showing?
Thank You
EPJ
Ps The setranges are last to first so that I end up at the start
because of this selection problem

Sub Macro32()
'
' Macro32 Macro
' Go to day 2 (Ladies)
'

'
Application.ScreenUpdating = False
Columns("C:C").Select
ActiveWindow.FreezePanes = True
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 19
ActiveWindow.ScrollColumn = 20
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 23
ActiveWindow.ScrollColumn = 24
ActiveWindow.ScrollColumn = 25
ActiveWindow.ScrollColumn = 26
ActiveWindow.ScrollColumn = 27
ActiveWindow.ScrollColumn = 28
ActiveWindow.ScrollColumn = 29
ActiveWindow.ScrollColumn = 30
ActiveWindow.ScrollColumn = 31
ActiveWindow.ScrollColumn = 33
ActiveWindow.ScrollColumn = 34
ActiveWindow.ScrollColumn = 35
ActiveWindow.ScrollColumn = 37
ActiveWindow.ScrollColumn = 38
ActiveWindow.ScrollColumn = 40
ActiveWindow.ScrollColumn = 41
ActiveWindow.ScrollColumn = 42
ActiveWindow.ScrollColumn = 44
ActiveWindow.ScrollColumn = 45
ActiveWindow.ScrollColumn = 46
ActiveWindow.ScrollColumn = 47
ActiveWindow.ScrollColumn = 48
ActiveWindow.ScrollColumn = 49
ActiveWindow.ScrollColumn = 50
ActiveWindow.ScrollColumn = 51
ActiveWindow.ScrollColumn = 52
ActiveWindow.ScrollColumn = 53
ActiveWindow.ScrollColumn = 55
ActiveWindow.ScrollColumn = 56
ActiveWindow.ScrollColumn = 57
ActiveWindow.ScrollColumn = 60
ActiveWindow.ScrollColumn = 62
ActiveWindow.ScrollColumn = 64
ActiveWindow.ScrollColumn = 67
ActiveWindow.ScrollColumn = 69
ActiveWindow.ScrollColumn = 70
ActiveWindow.ScrollColumn = 71
ActiveWindow.ScrollColumn = 72
ActiveWindow.ScrollColumn = 73
ActiveWindow.ScrollColumn = 74
ActiveWindow.ScrollColumn = 75
ActiveWindow.ScrollColumn = 76
ActiveWindow.ScrollColumn = 77
ActiveWindow.ScrollColumn = 78
ActiveWindow.ScrollColumn = 79
ActiveWindow.ScrollColumn = 80
ActiveWindow.ScrollColumn = 81
ActiveWindow.ScrollColumn = 82
ActiveWindow.ScrollColumn = 83
ActiveWindow.ScrollColumn = 84
ActiveWindow.ScrollColumn = 85
ActiveWindow.ScrollColumn = 87
ActiveWindow.ScrollColumn = 88
ActiveWindow.ScrollColumn = 89
ActiveWindow.ScrollColumn = 90
ActiveWindow.ScrollColumn = 91
ActiveWindow.ScrollColumn = 93
ActiveWindow.ScrollColumn = 94
ActiveWindow.ScrollColumn = 95
ActiveWindow.ScrollColumn = 96
ActiveWindow.ScrollColumn = 98
ActiveWindow.ScrollColumn = 102
ActiveWindow.ScrollColumn = 103
ActiveWindow.ScrollColumn = 104
ActiveWindow.ScrollColumn = 106
ActiveWindow.ScrollColumn = 108
ActiveWindow.ScrollColumn = 109
ActiveWindow.ScrollColumn = 110
ActiveWindow.ScrollColumn = 111
ActiveWindow.ScrollColumn = 112
ActiveWindow.ScrollColumn = 113
ActiveWindow.ScrollColumn = 115
ActiveWindow.ScrollColumn = 116
ActiveWindow.ScrollColumn = 117
ActiveWindow.ScrollColumn = 119
ActiveWindow.ScrollColumn = 121
ActiveWindow.ScrollColumn = 123
ActiveWindow.ScrollColumn = 124
ActiveWindow.ScrollColumn = 127
ActiveWindow.ScrollColumn = 128
ActiveWindow.ScrollColumn = 130
ActiveWindow.ScrollColumn = 132
ActiveWindow.ScrollColumn = 133
ActiveWindow.ScrollColumn = 134
ActiveWindow.ScrollColumn = 135
ActiveWindow.ScrollColumn = 137
ActiveWindow.ScrollColumn = 138
ActiveWindow.ScrollColumn = 139
ActiveWindow.ScrollColumn = 140
ActiveWindow.ScrollColumn = 141
ActiveWindow.ScrollColumn = 142
ActiveWindow.ScrollColumn = 144
ActiveWindow.ScrollColumn = 145
ActiveWindow.ScrollColumn = 146
ActiveWindow.ScrollColumn = 147
ActiveWindow.ScrollColumn = 148
ActiveWindow.ScrollColumn = 150
ActiveWindow.ScrollColumn = 151
ActiveWindow.ScrollColumn = 152
ActiveWindow.ScrollColumn = 153
ActiveWindow.ScrollColumn = 154
ActiveWindow.ScrollColumn = 155
ActiveWindow.ScrollColumn = 156
ActiveWindow.ScrollColumn = 157
ActiveWindow.ScrollColumn = 158
ActiveWindow.ScrollColumn = 160
ActiveWindow.ScrollColumn = 161
ActiveWindow.ScrollColumn = 162
ActiveWindow.ScrollColumn = 164
ActiveWindow.ScrollColumn = 165
ActiveWindow.ScrollColumn = 166
ActiveWindow.ScrollColumn = 168
ActiveWindow.ScrollColumn = 170
ActiveWindow.ScrollColumn = 172
ActiveWindow.ScrollColumn = 173
ActiveWindow.ScrollColumn = 174
ActiveWindow.ScrollColumn = 175
ActiveWindow.ScrollColumn = 176
ActiveWindow.ScrollColumn = 177
ActiveWindow.ScrollColumn = 179
ActiveWindow.ScrollColumn = 182
ActiveWindow.ScrollColumn = 183
ActiveWindow.ScrollColumn = 184
ActiveWindow.ScrollColumn = 185
ActiveWindow.ScrollColumn = 186
ActiveWindow.ScrollColumn = 185
ActiveWindow.ScrollColumn = 184
ActiveWindow.ScrollColumn = 183
ActiveWindow.ScrollColumn = 182
ActiveWindow.ScrollColumn = 181
ActiveWindow.ScrollColumn = 180
ActiveWindow.ScrollColumn = 179
ActiveWindow.ScrollColumn = 180
ActiveWindow.ScrollColumn = 181
ActiveWindow.ScrollColumn = 182
ActiveWindow.ScrollColumn = 183
ActiveWindow.ScrollColumn = 184
ActiveWindow.ScrollColumn = 183
ActiveWindow.ScrollColumn = 182
ActiveWindow.ScrollColumn = 183
ActiveSheet.Unprotect
SetRange =
Range("C179:T180,C182:T183,C185:T186,C188:T189,C191:T192,C194:T195,C197:T198,C200:T201").Select
Selection.Locked = True
Selection.FormulaHidden = False
SetRange =
Range("C104:T105,C107:T108,C110:T111,C113:T114,C116:T117,C119:T120,C122:T123,C125:T126,C128:T129,C131:T132,C134:T135,C137:T138,C140:T141,C143:T144,C146:T147,C149:T150,C152:T153,C155:T156,C158:T159,C161:T162,C164:T165,C167:T168,C170:T171,C173:T174,C176:T177").Select
Selection.Locked = True
Selection.FormulaHidden = False
SetRange =
Range("C8:T9,C11:T12,C14:T15,C17:T18,C20:T21,C23:T24,C26:T27,C29:T30,C32:T33,C35:T36,C38:T39,C41:T42,C44:T45,C47:T48,C50:T51,C53:T54,C56:T57,C59:T60,C62:T63,C65:T66,C68:T69,C71:T72,C74:T75,C77:T78,C80:T81,C83:T84,C86:T87,C89:T90,C92:T93,C95:T96,C98:T99,C101:T102").Select
Selection.Locked = True
Selection.FormulaHidden = False
SetRange = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True

End Sub


Sub Macro33()
'
' Macro33 Macro
' Back to Day 1 (Ladies)
'

Application.ScreenUpdating = False
ActiveSheet.Unprotect
SetRange =
Range("C179:T180,C182:T183,C185:T186,C188:T189,C191:T192,C194:T195,C197:T198,C200:T201").Select
Selection.Locked = False
Selection.FormulaHidden = False
SetRange =
Range("C104:T105,C107:T108,C110:T111,C113:T114,C116:T117,C119:T120,C122:T123,C125:T126,C128:T129,C131:T132,C134:T135,C137:T138,C140:T141,C143:T144,C146:T147,C149:T150,C152:T153,C155:T156,C158:T159,C161:T162,C164:T165,C167:T168,C170:T171,C173:T174,C176:T177").Select
Selection.Locked = False
Selection.FormulaHidden = False
SetRange =
Range("C8:T9,C11:T12,C14:T15,C17:T18,C20:T21,C23:T24,C26:T27,C29:T30,C32:T33,C35:T36,C38:T39,C41:T42,C44:T45,C47:T48,C50:T51,C53:T54,C56:T57,C59:T60,C62:T63,C65:T66,C68:T69,C71:T72,C74:T75,C77:T78,C80:T81,C83:T84,C86:T87,C89:T90,C92:T93,C95:T96,C98:T99,C101:T102").Select
Selection.Locked = False
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
ActiveWindow.FreezePanes = False
End Sub
 
I

igorek

why dont you activate a cell A1 after the code is done running ?
Activesheet.range("A1").select
 
J

jambun

Brilliant Igorek, I Knew there had to be a command but I couldn't work
out which one. Thanks
 
Top