+ Reply to Thread
Results 1 to 4 of 4

create list in a message box from range

Hybrid View

  1. #1
    Registered User
    Join Date
    12-11-2006
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    86

    create list in a message box from range

    Hi Everyone

    I want to show a message that will contain the names of people in a range that is updated regularly. I am using the following code:

    Sub Dist_List()
    Application.ScreenUpdating = False
    
    Range("D2").Select
        Dim strMsg As String
        Do Until IsEmpty(ActiveCell)
        strMsg = "The following people are currently on the Message Distribution list:" & vbCrLf & vbNewLine
        strMsg = strMsg & "     • " & Range("D2").Value & vbNewLine
        ActiveCell.Offset(1, 0).Select
          Loop
                      
        MsgBox strMsg, vbInformation, "Distribution List"
    
    Application.ScreenUpdating = True
    End Sub
    The problem I have is , it will only show the person who's name is in cell D2. I have a named range (email2) which currently spans cells D2:D10, but as I said previously, the range can and will grow.

    Does anyone have any suggestions?

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try
    Option Explicit
    
    Sub Dist_List()
        Dim rng    As Range
        Dim Cl     As Range
        Dim strMsg As String
    
        Set rng = Range(Cells(2, 4), Cells(Rows.Count, 4).End(xlUp))
    
        strMsg = "The following people are currently on the Message Distribution list:" & vbCrLf & vbNewLine
        For Each Cl In rng
            strMsg = strMsg & "     • " & Cl.Value & vbNewLine
        Next Cl
        MsgBox strMsg, vbInformation, "Distribution List"
    
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    12-11-2006
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2007
    Posts
    86
    Thank you once again RoyUK, it works perfectly!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Glad it helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create combobox list from autofiltered range without advance filter.
    By GravityInvert in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-26-2008, 04:22 AM
  2. List values from range, that aren't in range
    By Kenny J in forum Excel General
    Replies: 1
    Last Post: 06-24-2008, 01:54 AM
  3. vba code to create a list from data in one field
    By short_n_curly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2007, 11:16 AM
  4. Create HTML link from a list of domains
    By bumblestork in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-19-2007, 03:18 AM
  5. List and Create List
    By Magikey in forum Excel General
    Replies: 2
    Last Post: 11-09-2006, 12:41 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1