+ Reply to Thread
Results 1 to 38 of 38

VBA Macros to add text to present string by clicking

  1. #1
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    VBA Macros to add text to present string by clicking

    Hello,

    I am seeking for a help to Concatenate text. Here is the details. I have a value in A1 i.e.Text & Num both and i want to add another cell value by clicking on that cell in the same sheet.

    Example:
    Column A Column B Column C
    Excel Forum .Com

    Result:
    Column A Column B Column C

    Excelforum.com

    By clicking the cell it should take that value and added to A1. Something like Concatenate.

    Can it be possible.

    I it is only assuming so i don;t attached sample file.

  2. #2
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: VBA Macros to add text to present string by clicking

    This seems to work

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    Thanks for your reply i have forget to tell you.it should cut the text from active cell and past it to the first column. But i was changing the rows. Your script is addting to A1 only.

    So, need to complete column. Means if select B3 it should add to B1. If i select D5 the it should add to D1.

    My actual column is B.

  4. #4
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    can someone please

  5. #5
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    I am attaching the sample file. I have copy a limited data as a sample to grab the idea for a person who is going to help me. The actual file is 110 mb.

    I have attached sample file below.

    Just check C52, C53 & D71

    When i click or select the above mentioned cell it should add to same row column B.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    I have found on other website.

    You are expert to understand and edit according to my request. Check the code below:-

    It is asking 3 input box but what i want here is i will select first the cell which i want to copy and select the second cell where i will keep the original text + the first selection. I hope you understand.

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: VBA Macros to add text to present string by clicking

    I think what you are trying to do is move "Level 1" and "Level 2" data into the description field(Column B). Is this correct?

    If this is correct, then the following code should work.

    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    Can you check script which i have posted.

    Most critical problem is cell and columns are not accurate. I have just given example. My original file is having multiple columns.

  9. #9
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    I ahve check your script it is replacing the original text instead of adding to original

  10. #10
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: VBA Macros to add text to present string by clicking

    I think what you are trying to do is move "Level 1" and "Level 2" data into the description field(Column B). Is this correct?

    If this is correct, then the following code should work.

    Please Login or Register  to view this content.
    Sorry, my bad. I forgot the original value in B column.

  11. #11
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    I have found this script which meet to my requirement 99%. Only the issue with this script is it is ask the user to enter the cell address, where as i want to just select the cell address it should take automatically.

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    hec: do you want to add to column B the value from columns C and D when these are not empty? Also, do you want to leave a space between them? Also, should I delete after you add from column C or D once, so that you can't accidentally add it again?

    BTW, if your target cells aren't fixed somehow, like the output is column B and you add to it what's in column C and D, then you WILL need to input the cells address. If it is like a typed above, then I know a way to do it.
    .?*??)
    `?.???.?*??)?.?*?)
    (?.?? (?.?
    Pichingualas <---
    ??????????????????????????

    Wrap your code with CODE TAGS.
    Thank those who helped you, Don't forget to add to their REPUTATION!!! (click on the star below their post).
    Please mark your threads as [SOLVED] when they are (Thread Tools->Mark thread as Solved).

  13. #13
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    My problem is i ahve lot of data in Columns C, D, E, F,H, I.

    Ofcourse i want to add space inbetween the space.More important it should select multiple range i.e D5:D7

    Yes ofcourse it should do something like Cut & Past to the original text.

    I hope this will be the last requirement for my request.

  14. #14
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Quote Originally Posted by hecgroups View Post
    I hope this will be the last requirement for my request.
    Just making sure I understand what you need, sorry if it bothers.

    You want to add it to the same row tho right? (D5 should be added to B5, D6 should be added to B6, D7 should be added to B7...)

    Also, what's the total amount of columns? Up to and including column I? Is it true that the output cell is in column B (you didn't answer on your last post)?

  15. #15
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    Out put should be in column But the problem is some cell values i have to take and some i have to ignore. Due to this solution i have post a script in post #11 which meets my requirement 99%.

    The only issue with that script is it is asking to enter the single cell value where as i want to select the range to the destination. If you fix it i will be very thankful to you.

  16. #16
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    I have made a simpler code which might do what you need. Just select your test range and try it out. Do it with F8 if you want to see how it works. Here it goes:

    Please Login or Register  to view this content.
    I hope that helps.

  17. #17
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    BTW do not select column B too.

  18. #18
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    Hat's off to you boss. You do not know what a valuable help have provided to me from your side. I thanks to you from bottom of my heart. It works find and easier then i was thinking. Just select the cell and it goes to destination.

    Topic marked as closed and reputation is added.

  19. #19
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Glad to help

  20. #20
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    I it possible to same logic to extract last 2 letter and past it in column E.

  21. #21
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Sure it is. Last 2 letters of which column?

  22. #22
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Try with this:

    Please Login or Register  to view this content.
    Last edited by Pichingualas; 03-27-2012 at 03:19 PM. Reason: Changed sub name a little

  23. #23
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Not sure if you wanted to delete the cells copied on this one too. If not, delete the line
    Please Login or Register  to view this content.
    I hope that helps.

  24. #24
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    There it is i want to extract last 2 letter from my selection.

    Also please give me details for script to joint text might be i will use that script in other files also.

  25. #25
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    The way I'm joining strings in the code above is simply adding to what was already there what I want it to have. That's why I put it like
    Please Login or Register  to view this content.
    which is in reality joining together three sets of strings, as the space counts as a string too. You can add that way any amount of strings you need,
    Please Login or Register  to view this content.
    The & serves as a "join this after that"

    What I'm doing is use the first variation:
    Please Login or Register  to view this content.
    and make it work inside a loop where the str2 goes changing to the current x (which is each cell in your selected range) and str1 is what is in column B of the row where the current x is.
    Last edited by Pichingualas; 03-27-2012 at 03:33 PM.

  26. #26
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Did the code I posted above do what you needed? (add the 2 last letters of the selected range to the E column)

  27. #27
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    I think you misunderstand me.

    I said i want to EXTRACT the last 2 words. and one more thing it eh column E is having value then it should ask do you want to over right the resent text.

    I hope i make my self clear to you.

  28. #28
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    So what you want is to delete the last two letters of each cell in your selection? And have the user confirm if he wants to overwright column E or just delete those 2 letters?

  29. #29
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Mind you the first time you said letters and now you said words. Which is it you want?

  30. #30
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    I am sorry Letter.I want to cut those 2 letters from my selection and past it in Column E

    Example CB

  31. #31
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Ok, do you wish to replace what is in column E or add a space and the two letters?

  32. #32
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    If the Column E is not empty it should give message do you want to over right the present value Yes/No. If i select yes then it should cut the last 2 letter and past it in column E or if select no nothing will happen.

  33. #33
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Try with this:

    Please Login or Register  to view this content.
    I hope that helps.

  34. #34
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Slight change that will make it a bit better:

    Please Login or Register  to view this content.

  35. #35
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    Post #33 works fin for me it is perfect.

    If i wan tot change the column then what should i do to change the script please tell me.

  36. #36
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    The change in #34 isn't because #33 didn't work, it is to avoid asking if you want to overwrite it when the current cell you are looking at is empty. It will work just as fine, I advise you to use that one. As for what to change, its simple, change the cell you will be writing in:
    Please Login or Register  to view this content.
    That line says "make the value of the cell in column 5 from the current row (the one that our current x is in) equal the last two characters from the current cell (x)". So what you need to change in order to change the column from "E" to something else, is change the column number, in this case 5 for "E".
    Last edited by Pichingualas; 03-27-2012 at 04:20 PM.

  37. #37
    Valued Forum Contributor
    Join Date
    01-11-2012
    Location
    Riyadh, K.S.A.
    MS-Off Ver
    Windows 11 with Excel 2013 & 2016
    Posts
    900

    Re: VBA Macros to add text to present string by clicking

    Thanks to you for valuable help. Topic marked as solved and reputation added to you.

  38. #38
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: VBA Macros to add text to present string by clicking

    Thanks for the rep. Glad to help

+ 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