Loop within a loop based of condition

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
843
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I am not sure the best way to ask this. I have large code that I am looking to modify to include an additional loop that encloses my current code that has loops within it. The complexity I am struggling with is once I wrap my code within the new loop then it'll always run 2 loops but I only want to run the additional loop if a cell value is present. Before unleashing my whole code on you does the ask make sense? I know it will be hard to formulate without the guts of the code.
 
For simplicity I can work around it I can run the With FT for single or bulk submission and do 2 loops always. I just need to add a few more if then statements to support.

I was worried about performance if I didn't need to run that process (call secdisc2 for WsFT) would it tack on more time but was only 10 additional seconds. So moot point

When testing this out I got Variable not defined for "cell"

VBA Code:
For Each cell In CompList
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
My bad, use these rows:

VBA Code:
    Set BulkList = Range("BulkList")
    '<<><><><><>FIGURE OUT NEW LOOP FOR BULK LIST INCLUDING CODE BELOW Only if BUlk <> "" but not then do the exact same code<><><><><><>
Else
    For Each cell In BulkList.Cells ' <<<<<<<<<<< COULD ALSO BE SOMETHING LIKE "For bulkListIndex = 0 To BulkList.Count" IF THAT SUITS YOUR NEEDS BETTER >>>>>>>>>>>>
        'clear and set sheet filters
 
Upvote 0
All good I ended up trying this way

VBA Code:
'run for each fund
  j = 0
  Do Until WsFT.Range("BulkList").Offset(j, 0) = ""
    BulkList = WsFT.Range("BulkList").Offset(j, 0)

'my existing code

    j = j + 1
Loop

any drawback using this way, speed or efficiency you may think of? haven't fully test it yet anyways
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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