Apologies if this has been asked a different way but I couldn't find this issue anywhere...
I am creating a model to analyse test data and need to vary the size of my named ranges regularly, to account for the different number of learners on each course. I have used the following code to do this:
For i = 2 To 20
With ActiveWorkbook.Names("Question" & i)
.RefersTo = "Pivot Data 1 - To Use!$A$" & QuestionStart & ":$F$" & (LearnerNumbers + QuestionStart)
.Visible = True
End With
QuestionStart = QuestionStart + LearnerNumbers + 1
Next i
It successfully changes the size of my ranges (yay!) but when I use vlookup(a4, Question2, 3, FALSE) in my worksheet, excel returns the #VALUE! error.
On investigation with the Name Manager I found that the "Value" property is set to the same as the "Refers To" i.e. "Pivot Data 1 - To Use!$A$22:$F$37" rather than listing the contents of the range as expected.
I'm not sure what I have omitted from my code but any help will be much appreciated.
Thanks, Steph