Looking for a way to have the user select which sheets the code will run on

Status
Not open for further replies.

bakom002

New Member
Joined
Aug 19, 2019
Messages
11
I currently have vba code that runs through all of the named ranges in the workbook and for every sheet within an array of all the sheets in the work book it will find a specific named range and copy that data to different data dump location.

What I would like, is for the user to be able to select which sheets out of all the sheets in the workbook they want the code to run on specifically, instead of it running based on a defined/static array of sheets

Here is the part of the code that I would like to change:

Code:
Dim WshtNames As VariantDim WshtNameCrnt As Variant
Dim wb As Workbook
Set wb = ActiveWorkbook
Dim UpldNames As Variant
Dim UpldNameCrnt As Name


''''Determine applicable tabs. 
WshtNames = list of tabs with yellow boxes for upload purposes
WshtNames = Array("NewShare", "1590_Migration Depts", "PrjSvc", "Talent Mgmt CoE", "COS Intra-COS Alloc", "ADP RM", "Benefits CoE", "TLMeTimeUsage", "BenefitsToCOS", "Division", "TLM_CoE", "TLM_Depreciation", "FulfAllocSHPS", "FulfAllocNonSHPSBen", "ProB_COS", "PSC_COS", "COS_SASS")




For Each WshtNameCrnt In WshtNames
   With Worksheets(WshtNameCrnt)
   Worksheets(WshtNameCrnt).Activate
    
      For Each UpldNameCrnt In ActiveWorkbook.Names
         
         If Left(UpldNameCrnt.Name, 6) = "Upload" Then
            
              If UpldNameCrnt.RefersToRange.Parent.Name = ActiveSheet.Name Then
            
[THIS SECTION IS WHERE THE MAIN COPY/PASTE CODE GOES I LEFT IT OUT TO SAVE SPACE]             
              End If
          End If
       
       Next UpldNameCrnt

Thank you all in advanced for the assistance.
 

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)
Duplicate to https://www.mrexcel.com/forum/excel-questions/1107379-how-have-user-select-worksheets-run-macro.html

Please do not post the same question multiple times. Questions of a duplicate nature will be locked or deleted, per #12 of the Forum Rules and points 6 & 7 of the Forum Use Guidelines.

Note that posts from new members are sometimes 'held back' until they are approved by a moderator. That had happened with the above post and you would have been presented with a message to that effect. So in future, please be patient.

Any bumps, clarifications, or follow-ups should be posted to the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,576
Messages
6,120,354
Members
448,956
Latest member
Adamsxl

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