Cook09
asked on
Understanding certain aspects of Dynamic Legends for an Excel Chart
Attached is an Excel file that uses dynamic legends and values for a chart(s). Most of it is understood, but there are a couple questions about the retrieving and formatting of the Legends and some values. The questions are on the first page of the workbook.
Dynamic-Legends---Questions.xlsm
Dynamic-Legends---Questions.xlsm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think you are referring to this code:
rngCur is defined as a range variable in the function call. This is how VBA works.
I can create a new function, for example
At the same time as starting the function, I have declared three different variables. When the function is called, it will require three different parameters: a text string, a number and a range, like =MyTest("Hello",2015,$A$1)
While the function is running, it uses myString, myNumber and myRange as variables that have been populated with the parameters from the function call.
In the spreadsheets, the RangeWidth() function is used in a cell like this:
=RangeWidth(s.Legend)
So the s.Legend range is passed to the RangeWidth function. The statement
RangeWidth = rngCur.Width
will pass the width in points of that range (which is now represented by the rngCur variable) back to be used as the result of the function.
Function RangeWidth(rngCur As Range) As Single
''Calculate this macro each time the workbook is calculated
Application.Volatile
''Return the width, in points, for rngCur
RangeWidth = rngCur.Width
End Function
rngCur is defined as a range variable in the function call. This is how VBA works.
I can create a new function, for example
Function MyTest(myString as String, myNumber as Long, myRange as Range) as string
.... do something
end Function
At the same time as starting the function, I have declared three different variables. When the function is called, it will require three different parameters: a text string, a number and a range, like =MyTest("Hello",2015,$A$1)
While the function is running, it uses myString, myNumber and myRange as variables that have been populated with the parameters from the function call.
In the spreadsheets, the RangeWidth() function is used in a cell like this:
=RangeWidth(s.Legend)
So the s.Legend range is passed to the RangeWidth function. The statement
RangeWidth = rngCur.Width
will pass the width in points of that range (which is now represented by the rngCur variable) back to be used as the result of the function.
ASKER
teyln...I have tried four times to award a grade (A) and points (500), but it won't move the question as Solved...just abadoned. Can you help??
Cook09
Cook09
ASKER
Yes, this is one of Charley's, I'm on his subscription list...but the explanations behind some of the charts are a little weak.
The reason for question 2, is not being able to find the variable rngCurv. Normally, if a Named Range is selected, the Name of the Range will appear in the Name Box. But, I can't find where this variable is used within the UDF. The total is based upon pixels, but how is that calculated? rngCurv has to perform some conversion, or so it would seem. Would you have some insight on how this is being done?
I saw that the picture was LegendChoice, but is it one picture that changes its values and data based upon a particular Legend? If it's part of the Camera function, then at what point is a variable assigned to show the appropriate data?
Regards,
Cook09