Problems evaluating defined names in VBA
Thank's for all the help! I'm amazed that you take the time to help
me! First, it is supposed to be Datacolumnsmonth1 on both occasions (I
have from 1 to 12) and it is equal to 2, so the expression
SUBSTITUTE(ADDRESS(1,DataColumnsMonth1,3,,), 1,"") renders a "$B" and
the whole ugly indirect expression renders "Rawdata!$B:$B". I know it
is a lengthy way to get the B column, but that was the best way that I
could think of.
But then to the problem as such. Unfortunately I cannot use the range
methods, since the names do not refer to ranges as such, but to named
formulas. I have done a workaround, where I defined a UDF that would
copy in the value/function of the name in a cell and then I pick up
the result from that cell. That is of course a little bit slower,
since I have to jump between VBA and a worksheet, but that was the
only way I found to be working. So instead of using
Application.Evaluate("TotalNumberOfRowsData")
I use
EvaluateName("TotalNumberOfRowsData")
where EvaluateName is defined as below.
Function EvaluateName(InputName As String)
With Worksheets(HIDDENRANGESHEET)
.Cells(1, 2) = ActiveWorkbook.Names(InputName).Value
EvaluateName = .Cells(1, 2)
End With
End Function
This works and I get my answers. It still does not explain why I
couldn't use evaluate in the first place, but at least the program
runs.
Btw, what is the "locals window"?
Thanks and regards,
Anders M
|