+ Reply to Thread
Results 1 to 20 of 20

Concatenate Strings to specified column until last row

  1. #1
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Concatenate Strings to specified column until last row

    I am working on a macro how to concatenate the string "Proposal" and ":" in the Column B such that if the Column B consist a number 1 then the updated Column B has to be Proposal 1:. I know that the concatenation formula allows us to do that but i need to loop over until last row. Can anyone help me the macro that does this? here is the attached sample file.
    Attached Files Attached Files

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Concatenate Strings to specified column until last row

    Could you maybe just use a custom number format?
    • Select the cells to be impacted....example: B3:B100
    • CTRL+1
    ...Category: Custom
    ...Type: "Proposal "#\:
    ...Click: OK

    That will prepend Proposal to each number and append a colon.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Concatenate Strings to specified column until last row

    hi, the requirement is the same but I need a macro for doing that since I get this file on daily basis. And I need it to be done automatically by single click of button.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Concatenate Strings to specified column until last row

    If you want to change actual value in the cell then.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Concatenate Strings to specified column until last row

    Does this help?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Concatenate Strings to specified column until last row

    Hi john and jindon, thanks for the help. jindon I tried your code but I need the concatenation done to rows until the data is present. John, I tried your code as well I was testing it for more number of time and found that the if the Column B already has value "Proposal 12:" and when I ran your code it again concatenate the strings and gives as "Proposal Proposal 12::". I really appreciate your help.
    Last edited by mvneema; 03-18-2014 at 09:47 AM.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Concatenate Strings to specified column until last row

    Then try this one
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Concatenate Strings to specified column until last row

    Amended:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Concatenate Strings to specified column until last row

    Thank you all. What if I need to concatenate another column just like Column B. Say I need to add Column C with the String "Proposal Text". Do I need to add the range as "C" and add the same formula?

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Concatenate Strings to specified column until last row

    In that case change to
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Concatenate Strings to specified column until last row

    But I have different string to be concatenated into Column C "Proposal Text". I don't understand how resize work here?

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Concatenate Strings to specified column until last row

    Do you mean like this?
    Please Login or Register  to view this content.
    Last edited by jindon; 03-18-2014 at 10:31 AM. Reason: Add error proof

  13. #13
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Concatenate Strings to specified column until last row

    Yup what you meant is close. But if I need a random Column D to have concatenated with string "Vote 2013". Example, Column B concatenated with "Proposal " and Column D concatenated with "Vote 2013".

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Concatenate Strings to specified column until last row

    Alter Array as you want.
    First letter = Column reference, 2nd string = trailing string for respective column
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Concatenate Strings to specified column until last row

    hi john,
    when i tried hyour code that you specified in this post:
    Please Login or Register  to view this content.
    I just tried to concatenate 2 more columns with the string "Vote for 2013 and Vote for next year" I got it concatenated but when I run the macro second time it concatenate the strings twice. here is the code that I have modified.
    Please Login or Register  to view this content.
    Please help. I have attached the sample data sheet as well.
    Attached Files Attached Files

  16. #16
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Concatenate Strings to specified column until last row

    What do you need to happen. Why would you run it twice?

  17. #17
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Concatenate Strings to specified column until last row

    First of all, I get this sheet in daily basis and the user would run this macro to concatenate specific strings and then generate reports based on this. Sometimes there are chances that the user would trying running more than once which would lead to wrong text added in the report. So That is why I need the strings that are already concatenated to be added once again.
    For example,
    the column D and E should have string "Vote for 2013" and Vote for next year" concatenated to the values of the column for the first time the macro is hit. But for the second time if the string is already present then it should not be concatenated.
    Does that make sense?

  18. #18
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Concatenate Strings to specified column until last row

    Maybe this will give you more flexibility?

    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Concatenate Strings to specified column until last row

    Hi john,
    Now when I give the same column letter and string for the second time it prints the string twice. Example, first time execution the output of the macro is "Vote 2013 For: but second when I hit the macro button and I give the same column letter and string it gives me "Vote 2013 Vote 2013 For::". I don't want this to happen. I need it to be the same "Vote 2013 For:".

  20. #20
    Registered User
    Join Date
    02-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    76

    Re: Concatenate Strings to specified column until last row

    Hi john,
    Can you tell me why this code doesn't work for the column D and E but it worked for Column B. That is, Column B get its string "Proposal" concatenated only once (if the macro is hit twice)but for D and E it gets concatenated twice. I don't understand the logic here?
    Please Login or Register  to view this content.

+ 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. Concatenate two strings use it for Vlookup
    By Ajaysimha in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-21-2013, 09:47 AM
  2. Replies: 1
    Last Post: 12-20-2012, 04:18 PM
  3. Replies: 2
    Last Post: 06-16-2012, 06:20 PM
  4. Concatenate Strings in each cell
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-22-2009, 11:45 AM
  5. concatenate strings
    By Gary''s Student in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2005, 01:05 PM

Tags for this Thread

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