LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to set an arg list for my VBA functions

I see two problems with the code you posted. First, the elements of an Enum
must follow the same rules as for a variable name, so the space in your
first element of the thisLabelArg2 Enum cannot have a space in the middle of
it as you show. The second problem is in the 2nd argument for the thisLabel
function call shown here...

ChartTitle.Characters.Text = thisLabel(cumChartLabels, "Chart Title")

You are trying to pass "ChartTitle" as the 2nd argument; however,
"ChartTitle" is a String value, but your declaration for the 2nd argument is
a thisLabelArg2 Enum, which is not a String value. If you don't want to pick
the value from the drop down list (not sure why you wouldn't as you said in
your initial posting that is what you wanted to be able to do), you could
construct your function call this way...

ChartTitle.Characters.Text = thisLabel(cumChartLabels, _
thisLabelArg2.ChartTitle)

where I am assuming you are correcting your first mistake by simply removing
the internal space. You are also showing two End Function statements, but
I'm assuming that is from some bad Copy/Paste'ing. Also, while I don't think
it is contributing to any errors, I find your If-Then block construction
(especially without better indenting) to be very hard to read... I never use
one-line ElseIf statements like you showed. One final comment for when you
get this all working... inside your code, you do not have to use the 1, 2, 3
etc. equated values of your Enum elements, you can use EnumName.ElementName
instead. For example, instead of this...

If labelSeries = 1 Then

you could use this (more self-documenting) version instead

If labelSeries = thisLabelArg1.cumChartLabels Then

Rick


"shelfish" wrote in message
...
Many thanks. I'm getting a "User defined type not defined..." error.
Here's what I've got:

Public Enum thisLabelArg1
cumChartLabels = 1
monthlyCountChartLabels = 2
top5ChartLabels = 3
End Enum

Public Enum thisLabelArg2
Chart Title = 1
X_Axis_Label = 2
Primary_Axis_Label = 3
Secondary_Axis_Label = 4
End Enum

Function thisLabel(labelSeries As thisLabelArg1, labelType As
thisLabelArg2) As String ## Error on this line ##

If labelSeries = 1 Then Set thisChartLabel = cumChartLabels
ElseIf labelSeries = 2 Then Set thisChartLabel =
monthlyCountChartLabels
ElseIf labelSeries = 3 Then Set thisChartLabel =
top5ChartLabels
End If
If labelType = 1 Then findLabelType = "Chart Title"
ElseIf labelType = 2 Then findLabelType = "X Axis"
ElseIf labelType = 3 Then findLabelType = "Primary"
ElseIf labelType = 4 Then findLabelType = "Secondary"
End If

thisLabel = Range("'" & chartDataSheetName & "'!" &
thisChartLabel.Find(labelType).Offset(1, 0).Address).Value

End Function

thisLabel = Range("'" & chartDataSheetName & "'!" &
thisChartLabel.Find(labelType).Offset(1, 0).Address).Value

End Function

Sub...
...ChartTitle.Characters.Text = thisLabel(cumChartLabels, "Chart
Title")
End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
List Functions Brooklyn Excel Worksheet Functions 2 September 27th 08 04:57 AM
Identify & List unique values from a list using functions/formulas momtoaj Excel Worksheet Functions 3 May 31st 07 06:18 PM
Combining the IF and List functions [email protected] Excel Programming 1 July 3rd 06 09:50 PM
List of VBA Functions ExcelMonkey[_144_] Excel Programming 2 June 8th 04 04:56 PM
List all Functions James[_9_] Excel Programming 6 July 21st 03 06:07 PM


All times are GMT +1. The time now is 01:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"