+ Reply to Thread
Results 1 to 2 of 2

Passing multiple strings from Column A Worksheet to one Textbox in UserForm with commas if

  1. #1
    Registered User
    Join Date
    12-19-2010
    Location
    Oklahoma
    MS-Off Ver
    Excel 2007
    Posts
    22

    Question Passing multiple strings from Column A Worksheet to one Textbox in UserForm with commas if

    the value in column B is 1. So I have a userform with a textbox that I'm checking to see if

    Book1.xlsm

    In the textbox (TextBox1) on UserForm 1 I would like to be able to show the following in this case: a, c, e, g

    but I want to be able to have it work in case all values of column B are 1 such as: a, b, c, d, e, f, g, h

    Can this be done? I think I'm lacking the programming knowledge to see past this one. Any help would be greatly appreciated. I have attached the file above for sample in what I'm trying to do.

    Here is the code I have so far. I want the values to be in the textbox upon the form opening.

    Private Sub UserForm1_Initialize()

    Dim myarray As Variant
    myarray = Array(1, 8)

    For i = 1 To 8

    If ThisWorkbook.Sheets("Sheet1").Cells(i, 2).Value = 1 Then
    myarray(i) = ThisWorkbook.Sheets("Sheet1").Cells(i, 1).Value

    Me.TextBox1.Text = myarray(0) + ", " + myarray(1) + ", " + myarray(2) ' + ... etc. just continuing what I would assume should go here but I know I'm missing something

    End Sub

    Please help, thanks to all again!!!
    Last edited by pgreenway; 04-15-2014 at 11:33 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Passing multiple strings from Column A Worksheet to one Textbox in UserForm with comma

    Please Login or Register  to view this content.
    Note : The userform initialize procedure is always called exactly UserForm_Initialize and not something like UserForm1_Initialize.
    The "UserForm" in this case is not the name of the userform
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ 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. Replies: 4
    Last Post: 01-29-2014, 05:53 AM
  2. Split a long text in a userform textbox to multiple rows on a worksheet
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-31-2012, 09:03 AM
  3. [SOLVED] Passing multiple strings to variable in Replace Function
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2006, 01:10 PM
  4. Formatting Textbox, passing values to worksheet
    By Craig in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-06-2005, 09:00 PM
  5. [SOLVED] passing multiple strings to a function
    By Tijmen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2005, 06:05 PM

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