+ Reply to Thread
Results 1 to 9 of 9

Concatenate range

  1. #1
    Registered User
    Join Date
    11-17-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    43

    Concatenate range

    At work we sometimes have to input a long string of concatenated numbers into a field in our information system (ex: 1,2,3,4,5,6,7,8,9,10...etc).

    I found a code to accomplish this as follows:

    Please Login or Register  to view this content.

    And this works, but i want to make it more user friendly for my coworkers, whereas they click on a button (Button10_Click) and it prompts them with an inputBox asking for the range, which they can select with their mouse. It saves this range, and then enters it as the substrings into that concantenation script above. it has been a while since my VBA coding days and i kind of forget where to go from here.

    any suggestions would be appreciated.

    Thanks everyone.
    Last edited by DFrank231; 11-29-2011 at 11:21 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: need some help with macro to accept range input and concatenate

    hi DFrank231
    Welcome to the forum

    Try ...

    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: need some help with macro to accept range input and concatenate

    You're going to have a problem having the macro allow the user to select a range while the input box is on the screen.

    My hunch is that you will have to have a button launch a modaless form with 3 buttons on it.
    The user would select the range with the data in it, then click button 1.
    The user would select the cell where the results go, then click button 2.
    The user would then click button 3 to run the macro that concatenates the range and puts the result in the selected cell.

    If that sounds like what you want, I can get you started. I won't write the whole thing, but I would created the skeleton and you could just fill in the blanks.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  4. #4
    Registered User
    Join Date
    11-17-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: need some help with macro to accept range input and concatenate

    Thanks for the responses.

    foxguy, that could theorhetically work. you said i would have trouble selecting a range, but i was able to select one previously when i was messing around...but i couldnt figure out where to store that range and then pull it into the concRange macro.

    pike: where would i incorporate Button10_Click to run the input box?

    I'm sorry if this seems so basic, i havent coded VBA for 8 years but im trying to get back into it.

    I attached the file i am working on if that helps.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-17-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: need some help with macro to accept range input and concatenate

    nevermind! figured it out. thanks Pike.

  6. #6
    Registered User
    Join Date
    11-17-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: need some help with macro to accept range input and concatenate

    Now i am running into another problem...some values being input are too much for the code to handle and it is returning an improper amount....The attachement "error" shows what happens. I run a similar thing with numbers of different lengths and it works just fine (see correct.gif attached).

    The code i use is as follows...do i need to declare the TempConcRange variable as something else?

    Please Login or Register  to view this content.
    Attached Images Attached Images

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: need some help with macro to accept range input and concatenate

    do you have strings longer than 255

    http://support.microsoft.com/kb/105416

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: need some help with macro to accept range input and concatenate

    Excel is reading your concatination of numbers as a number.
    If you format Range("E9") as text you'll get the expected result.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  9. #9
    Registered User
    Join Date
    11-17-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: need some help with macro to accept range input and concatenate

    Thanks Marcol. That seems to have fixed it.

+ 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