+ Reply to Thread
Results 1 to 5 of 5

Pass cells from Custom Filter to a Text Box (w concatenation) using VBA Code

  1. #1
    Registered User
    Join Date
    10-05-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2013
    Posts
    4

    Pass cells from Custom Filter to a Text Box (w concatenation) using VBA Code

    I have a "stakeholder directory" that is operated by VBA code that affects a custom filter based on a drop-down. After the filter is complete, I'd like to have VBA code tied to a command button that cycles through all of the visible records of the filter and collects a cell value (an email address) and pastes it into a text box (concatenated by a comma and a space). The purpose is to produce an email list that can then easily be copied and pasted into the "To:" field of an email. I operate Excel 2013 on a Windows 7 machine.

    A video describing what I'm attempting to do can be found on YouTube via this URL: http://www.youtube.com/watch?v=Ayi_fcKdqRA

    On the attached xlsx file, reference the tab labeled "Sample."

    Thank you, very much, for your time and attention.

    Appreciatively,
    Eric
    Attached Files Attached Files

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Pass cells from Custom Filter to a Text Box (w concatenation) using VBA Code

    Hello Cirenav,

    Is the sheet being looked at the 'Data' sheet? Is the drop-down in cell AH6? Will the sheet already be filtered or will the macro need to filter it as part of the button click? Where should the results be output? I don't see a userform or textbox control where they can copy the result from.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    10-05-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2013
    Posts
    4

    Cool Re: Pass cells from Custom Filter to a Text Box (w concatenation) using VBA Code

    tigeravatar,

    The only worksheet we need to be concerned with is the fourth one, labeled, "Sample." Yes, the table will already be filtered (by way of existing VBA code tied to the drop-down in cell C1, highlighted in yellow). When the user makes a selection from the drop-down in C1, the table is already directed to filter accordingly. The VBA code I am requesting has no need to filter the data again. The VBA code I'm requesting only copies values from the table AFTER it has been filtered.

    Once the user makes a selection from the drop-down in C1, the table is designed to filter automatically. At that point, the user would click the command button called "Collect Emails." What I would like is VBA code (tied to that command button) which copies the email address from each of the visible records in the filtered data and pastes those values into a cell (let's say, H1) and the code would concatenate each email address with a comma and a space. Like this: (e.g., [email protected], [email protected], etc.). The text box that is located near the command button called "Collect Emails" will then be linked to H1 and will display all of the concatenated emails from the filtered table.

    I hope that description is a bit more clear. If not, I'll produce a quick video that will better describe my objective.

    Appreciatively,
    Cirenav


    tigeravat wrote:
    Re: Pass cells from Custom Filter to a Text Box (w concatenation) using VBA Code
    Hello Cirenav,

    Is the sheet being looked at the 'Data' sheet? Is the drop-down in cell AH6? Will the sheet already be filtered or will the macro need to filter it as part of the button click? Where should the results be output? I don't see a userform or textbox control where they can copy the result from.

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Pass cells from Custom Filter to a Text Box (w concatenation) using VBA Code

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-05-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2013
    Posts
    4

    Re: Pass cells from Custom Filter to a Text Box (w concatenation) using VBA Code

    tigeravatar,

    It seems like we must be close... When I try to run this sub, I get an error. Specifically, "Run-time error '91': Object variable or With block variable not set." The highlighted line is the one that starts "With Intersect...."

    Moreover, I'm not sure I understand the need for mentioning A6 anywhere in the code. It is just a blank cell. The first cell with any email-address data in it is B9.

    I made an effort to modify it myself and do some research on the Intersect function, but was unfruitful.

    I feel we are quite close.

    Thank you for your time. I strive to have such VBA fluency, one day.

+ 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. Use a userform to pass values from combo box to autofilter with custom filter for dates
    By Megatronixs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2013, 10:30 AM
  2. [SOLVED] IF Condition to date cells with concatenation of two text cells
    By desibird in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-26-2013, 03:28 PM
  3. [SOLVED] IF Condition: two cells with dates and concatenation of corresponding 2 text cells
    By desibird in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-25-2013, 10:38 AM
  4. Concatenation of Text in Arrays with reference cells
    By boscoamd in forum Excel General
    Replies: 4
    Last Post: 11-30-2011, 10:10 AM
  5. Custom Auto Filter VBA Code
    By balamus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-19-2005, 07:52 AM

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