Consulting

Results 1 to 6 of 6

Thread: Solved: Combining two cells in VBA

  1. #1

    Solved: Combining two cells in VBA

    Hi there, I've been working on an way of trying to get two separate values of data to combine into one value so it would be able to be outputted to a user form for some of my co-workers.

    One of the values is Text, the other is a number. What I am basically looking to do is figure out a way of having the VB side of things, automatically combine the two values, so if cell H2 read 'A' and I2 read '21' it would automatically fill out the other information in another column and give the value 'A21'.

    I'm not sure what kind of command or function would apply to this case specifically, and i was trying to look through some help files (and that did more damage than good). Any suggestions, tips/help would be greatly appreciated.
    Heaven won't take me.. Hell is afraid I'll take over... adn Purgatory doesn't have a smoking section... I am SO screwed...

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    In cell J2, put =H2&I2
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  3. #3
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    221
    Location
    I'm with Tony. Just have a cell in excel that already joins the information, and have vb pull that (in his example J2).

    An alternative option, is :
    [vba]
    TextBox1.Value = Sheets("sheet1").Range("A1") & ("a2")
    [/vba]
    .... i think first is far easier.

  4. #4
    actually, doing it that way slowed down the process entirely, Tony's suggestion that is. The problem is that this workbook is going to be getting up in size and could potentially go through about 2000 rows of data. It drastically slowed things down, however, the other way suggested using the ranges worked out phenomenally well.

    Thank you both for your suggestions on this, I truly do appreciate the help.
    Heaven won't take me.. Hell is afraid I'll take over... adn Purgatory doesn't have a smoking section... I am SO screwed...

  5. #5
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    I'm not sure I follow what you are doing but there is no way a trivial formula like that should have a significant performance hit on 2000 rows.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  6. #6
    well, i think that it was doing teh slowdown was that teh data got entered into one worksheet, adn the total was output on another sheet, if i neglected to mention that I'm sorry. ^^;
    Heaven won't take me.. Hell is afraid I'll take over... adn Purgatory doesn't have a smoking section... I am SO screwed...

Posting Permissions

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