+ Reply to Thread
Results 1 to 3 of 3

Concatenate text and checkbox data entered in userform

  1. #1
    Registered User
    Join Date
    08-10-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Exclamation Concatenate text and checkbox data entered in userform

    Hi,

    I'm new to VBA, but trying to learn quickly. Attached is a userform I have created but I'm struggling with the required code.
    The code I am looking for will concatenate the text from job number and BU with selections made in region and head code check boxes and put in column A and description entered put in column B.
    For example , if JOP0004E is typed in job number field and BU is 20 and NSW, VIC, QLD are checked and 62, 63 are checked the following combinations would be recorded in column A (column B description is always the same)
    2022EXP62JOP0004E
    2022EXP63JOP0004E
    3022EXP62JOP0004E
    3022EXP63JOP0004E
    4022EXP62JOP0004E
    4022EXP63JOP0004E

    The leading two numbers relate to region and are as follows:
    NATIONAL = 10
    NSW = 20
    VIC = 30
    QLD = 40
    SA = 50
    WA = 60

    There is only one exception rule which I would like included. If NATIONAL is checked, it doesn't matter what head codes are checked, it will only setup head code 64 eg
    1022EXP64JOP0004E

    If any of this doesn't make sense I'm more than happy to explain further. If someone can just get me started with the code, I'm happy to put in the various combinations if this is what's needed.

    Many thanks for your assistance.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor jwright650's Avatar
    Join Date
    12-10-2010
    Location
    Va, USA
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    606

    Re: Concatenate text and checkbox data entered in userform

    You can concatenate the strings by simply...using the "&" symbol

    "text" & "text" & "text" = "texttexttext"

    to add spaces (if needed) "text" & "" & "text" & "" & "text" = "text text text"

    When you write your code the textbox.value or textbox.text strings can be concatenated the same way...doesn't matter if it's comboboxes, or captions, or range/cell values...it will string them together.

    ie. Here is where one of my userforms is writing to the worksheet.

    Please Login or Register  to view this content.
    the end result on my worksheet is written in F17, this text:
    "PART OF CONTRACT: ITEM#.....plus the value in textbox named "txtItemNum" so if that value was "4", it would read:
    "PART OF CONTRACT: ITEM# 4"

    Hope that helps,
    Last edited by jwright650; 01-27-2011 at 02:51 PM. Reason: repaired some of my mis-spellings
    Life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
    John Wright

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Concatenate text and checkbox data entered in userform

    Cross posted here? http://www.ozgrid.com/forum/showthread.php?t=150128
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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