Class Module Triggered by multiple Target.Cell(1).Addresses

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
437
Good day,

I have a dashboard on a worksheet that has 50-60 numbers, when you click on any of those numbers a 30-day trend on a userform appears. In my excel vba naivety I inserted 50-60 userforms all with identical code to form the graph. Everything works but boy, what a waste!

I have 50-60 trigger events as shown below (just first 5 shown). How do I lump them all 50-60 of these calls together and call a single class module userform when I click on any of those cells? I have figured out all the class module code - all I need to learn is how to trigger it with all the Target.Addresses I have.

Code:
 If Target.Address = "$K$10" Then
        A212PRODUCTPCTS.Show vbModeless
    End If
    
If Target.Cells(1).Address = "$C$14" Then
        A212FLOWWATER.Show vbModeless
    End If
    
If Target.Cells(1).Address = "$H$12" Then
        A212FLOWSMD.Show vbModeless
    End If
    
If Target.Cells(1).Address = "$M$17" Then
        A212FLOWCON.Show vbModeless
    End If
    
If Target.Cells(1).Address = "$W$19" Then
        A212FLOWCPL.Show vbModeless
    End If
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You could do something like this:

Code:
If Not Intersect(Target, Range("K10,C14,H12,M17,W19")) Is nothing Then
        combined_form.Show vbModeless
    End If
 
Upvote 0
Thanks Rory... did a count of these numbers. There's over 150 of them (sorry for the miscount) and yes, my file has a userform for each one. Might you comment on the feasibility of this plan

step#1 - Encompass all the numbers in a named range
step#2 - For each cell is range, if "isnumber" then add to an array
step#3 - Perform your intersect function as Intersect(Target, array)

John
 
Upvote 0
I'm not clear on why you need step 2. If Target intersects the named range, do whatever you need to do.
 
Upvote 0
The numbers are not in neat rows and columns, they are spaced on in a 'map' and there are empty cells between them.
 
Upvote 0
If your named range only includes the populated cells, that won't matter.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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