Nested Loop?

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

Have the following code which works fine but I think it can be reduced by placing into a nested loop, but I'm not sure how to make sure the string variables are built up properly:
Code:
e = Range("EmailList").Row + 1
Do
    Email_List = Email_List & Cells(e, c) & "; "
    e = e + 1
Loop Until IsEmpty(Cells(e, c))

e = Range("EmailList").Row + 1
Do
    Email_CC = Email_CC & Cells(e, c + 1) & "; "
    e = e + 1
Loop Until IsEmpty(Cells(e, c + 1))

e = Range("EmailList").Row + 1
Do
    Email_BCC = Email_BCC & Cells(e, c + 2) & "; "
    e = e + 1
Loop Until IsEmpty(Cells(e, c + 2))
Can this be nested?

Jack
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Thought of this but I question if it's an improvement (probably not then):
Code:
Dim i As Long
e = range("EmailList").Row + 1
For i = 0 To 2
    Do
        TempS = TempS & Cells(e, c + i) & "; "
        e = e + 1
    Loop Until IsEmpty(Cells(e, c + i))
    
    Select Case i
        Case 0
            Email_List = TempS
        Case 1
            Email_CC = TempS
        Case 2
            Email_BCC = TempS
    End Select
    
    e = range("EmailList").Row + 1
    TempS = Empty
    
Next i
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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