Good Afternoon.
Having just developed a Rostering package in Excel, I forgot to name ranges as I was going along.
I want to name certain ranges on each sheet with the same names (station names) so that to go to a certain station, a macro will simply pick a range and go to it.
In other words, there will be a combo box which you select (for example new pudsey) and whichever sheet you are on, it will take you to a certain range, named 'npd'.
I have written the following vba code
Sub IdentifyRanges()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
'Name ranges
Range("a1162:n1216").Name = "MISC"
Range("a366:n385").Name = "NPD"
And so on for about thirty entries
Range("a1092:n1111").Name = "WNYTL"
Range("a945:n965").Name = "WRK"
Next
End Sub
Yet it stops abruptly, part way through with a simple message box saying '400'. Any ideas why? (Excel 2007)
Thanks
Chris
Having just developed a Rostering package in Excel, I forgot to name ranges as I was going along.
I want to name certain ranges on each sheet with the same names (station names) so that to go to a certain station, a macro will simply pick a range and go to it.
In other words, there will be a combo box which you select (for example new pudsey) and whichever sheet you are on, it will take you to a certain range, named 'npd'.
I have written the following vba code
Sub IdentifyRanges()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
'Name ranges
Range("a1162:n1216").Name = "MISC"
Range("a366:n385").Name = "NPD"
And so on for about thirty entries
Range("a1092:n1111").Name = "WNYTL"
Range("a945:n965").Name = "WRK"
Next
End Sub
Yet it stops abruptly, part way through with a simple message box saying '400'. Any ideas why? (Excel 2007)
Thanks
Chris