Help needed with menu activated macro, please

greegan

Well-known Member
Joined
Nov 18, 2009
Messages
644
Office Version
  1. 365
Platform
  1. Windows
Group1,Group2,Group3,Group4,Group5
X001,X011,X012,X300,X001
X004,X013,X200,X301,X004
X007,X014,X201,X302,X007
X008,X015,X202,X303,X008
X009,X016,X203,,X009
X010,X033,X204,,X010
X034,X035,X205,,X011
,X036,X206,,X012
,X037,X207,,X013
,X038,X220,,X014
,,X224,,X015
,,X225,,X016
,,,,X033
,,,,X034
,,,,X035
,,,,X036
,,,,X037
,,,,X038
,,,,X200
,,,,X201
,,,,X202
,,,,X203
,,,,X204
,,,,X205
,,,,X206
,,,,X207
,,,,X220
,,,,X224
,,,,X225

The above is an Excel table (sorry I cannot use the table app this site has while at work) and I need your help.
I need a menu execution that will let the user choose to process Group # and will only affect the worksheets named from the above list under that Group #.
Each of my macros does basically the same thing except they are reliant on the Group # and the worksheet name.
Each macro opens the xlsx file with the "x" sheet names, and data is processed within the workbook. From there it is added to the Group worksheet in the list.

I hope this is enough information to help you help me to get started in the right direction. It was suggested to me by an associate that i might be able to use an array to identify the sheets but it wasn't made clear and the associate isn't available to explain further. Thank you for all of your help and advice.

-- g
 
If you create named ranges for each group, you can do something like this:

Code:
Sub x()
    Dim cell        As Range
    Dim wks         As Worksheet
 
    For Each cell In Range("Group3").Cells
        Set wks = Nothing
        On Error Resume Next
        Set wks = Worksheets(cell.Text)
        On Error GoTo 0
 
        If Not wks Is Nothing Then
            myMacro wks
        End If
    Next cell
End Sub
 
Sub myMacro(wks As Worksheet)
    With wks
        '...
    End With
End Sub
 
Upvote 0
Thank you again for your answer. How would you recommend I did this with a table. Each of the table headers I suppose represent the name of the ranges you mentioned.

-- g
 
Upvote 0

Forum statistics

Threads
1,226,797
Messages
6,193,051
Members
453,772
Latest member
aastupin

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