VBA Loop and respective worksheets

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
793
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Need some help or pointed in a direction to handle a roadblock I have on my VBA. See below:

in laymans terms I am setting a range, clearing the macro, running a macro with the set range, then repeating. The part I need to include is before going to the next range it needs to transfer it its respective sheet. That part I don't know how to map the range to its respective sheet.

Ranges are like this: A####, B####, and etc.
Sheets: A, B and etc.
So A#### with Sheet A and so forth

VBA Code:
' Run loop for range
i = 1
Do Until Sheets("Loop").Range("FILTER").Offset(i, 0) = ""
FILTER = Sheets("Loop").Range("FILTER").Offset(i, 0)
Sheets("Security").Range("REQ") = FILTER
Call Clear
Call SECDIS
i = i + 1
Loop

Any help is warranted. i have 18 ranges. so it seems tedious and not very efficient to code that all out 18 times to accomplish.
 
Yes it sure is and did stumble on generic ways. With the loop I have a wild card though. I can't do like the attached because I am not always looking for A and if not there set to A. I will test out a few ideas will give the below a try and see if it works.

VBA Code:
On Error Resume Next
    If Not Worksheets(SheetName).Name = WsCus.Range("FILTER").Offset(i, -1).Value Then Worksheets.Add.Name = WsCus.Range("FILTER").Offset(i, -1).Value
On Error GoTo 0
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Yes it sure is and did stumble on generic ways. With the loop I have a wild card though. I can't do like the attached because I am not always looking for A and if not there set to A. I will test out a few ideas will give the below a try and see if it works.

VBA Code:
On Error Resume Next
    If Not Worksheets(SheetName).Name = WsCus.Range("FILTER").Offset(i, -1).Value Then Worksheets.Add.Name = WsCus.Range("FILTER").Offset(i, -1).Value
On Error GoTo 0
this worked just for any future reference.
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,068
Members
449,091
Latest member
remmuS24

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