A few things that I notice
Range("CompSubBranch") = Empty
Empty is used as an unitialized vaiable. Just use
Range("CompSubBranch") = ""
For a validation (between) I expect a Formula like
Formula1:="1", Formula2:="3"
I would not use this : Sheet1.Protect
Instead
Dim Ws1 as Worksheet
Set Ws1 = Worksheets("Sheet1")
Ws1.Protect
why have
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
When the strings are "" (empty) ?
I understand that your rng goes upto Q200, but where it could go wrong:
Function GetRange(val As Integer) As String
Dim startPnt As Integer
Dim endPnt As Integer
For Each Item In Range("'List'!Q2:Q200")
If Item.Value = val And startPnt = Empty Then startPnt = Item.Row
If Item.Value = (val + 1) And endPnt = Empty Or Item.Value = Empty And endPnt =Empty Then endPnt = Item.Row - 1
Next
GetRange = "$P" & startPnt & ":$P" & endPnt
End Function
Use startPnt = "" and
An integer can take values up to 32,767.
startPnt = Item.Row, so theoretically it can become as large as Cells.rows.Count, which is already 65,536 in XL2003.
This will give an overflow error '6'
Where it goes wrong (I think) is here Range("'List'!Q2:Q200")
Set WsList = Worksheets("List")
For Each Item In WsList.Range("Q2:Q200")
Bookmarks