Mimick a first click of a created on demand object

Puertorekinsam

Active Member
Joined
Oct 8, 2005
Messages
293
I have a userform that during run time creates 256 individual labels (they represent 5 charts with 53 weeks of data).
This works great, I move the axis and scale as needed, I color code them based upon data in the spreadsheets, they have control tips to show their full value.s

I also have them all exist as a part of a class this way, when one is clicked, all five charts highlight the same "week" and load some information into group of labels to give full context of the selected week.
Again, this part works great.

What I can't figure out is how to pragmatically call the label click for the last generated label. This way the form is fully filled out when it initially shows up.
If the labels existed before the form is generated, I would easily just have

Code:
call Rev52_Click

But if I put that code in, I am told "Sub or function not defined". Which totally makes sense


I saw something about using the CallByName but I'm not sure how to use that with a class item:

I have this code after two for loops,
one runs through the 5 metrics displayed in the charts... the last one giving the variable "MetName" the value of "REV"
The second loops through the 52 bars on the chart (0-52) and loads that into the variable i

Code:
    strName = MetName & (i - 1) & "_Click"
    CallByName Me, strName, VbMethod

In callByName, I have tried: "ME", "LongTermTrends" (the name of the userform), "Class3", "LongTermCharts" (the name of the object in the class that has events)

Here are all the versions I've tried that don't seem to work (with full names writen out)
Code:
CallByName Me, "Rev52_Click", VbMethod
CallByName LongTermTrends, "Rev52_Click", VbMethod
CallByName Class3, "Rev52_Click", VbMethod
CallByName LongTermCharts, "Rev52_Click", VbMethod
CallByName Class3, "LongTermCharts_Click", VbMethod

Thanks for the help!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I just needed to sleep on it.

I wound up moving the code from the Class Click into a separate sub in a regular module with a variable for the name of the label, and a variable for the tag of the label. I called this sub from the class click, and then hard coded it to to the end of the form initialize sub routine.
 
Upvote 0

Forum statistics

Threads
1,224,749
Messages
6,180,727
Members
452,995
Latest member
isldboy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top