+ Reply to Thread
Results 1 to 21 of 21

Concatenating cell values

  1. #1
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Concatenating cell values

    I've been doing crazy searchs to try and find something like this......This is so close to what I'm looking for. How would I modify this script to make it a little more strict. I need to put this in about 100 cells I need it to see if the result is = to 5 if so extract text from Column A (Always) and make a list like this script is doing. I hope that makes sense.

    Refers to this post:
    http://www.excelforum.com/excel-gene...in-a-cell.html
    Last edited by Ron Coderre; 11-06-2012 at 09:42 AM.

  2. #2
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: How to pull values from a column, and list them in a cell

    Infact I've changed just one thing and it's getting even closer. So if I change it to the script below I get 5,5. This is close. But instead of it grabing the text in that box. I need to get the in text from that same row from Column A. After seeing this I know it can work..... I'm actually getting really excited.

    Please Login or Register  to view this content.
    Last edited by tray262; 11-08-2012 at 07:55 AM.

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

    Re: How to pull values from a column, and list them in a cell

    I think this code does what you want:

    Please Login or Register  to view this content.
    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Concatenating cell values

    It work flawlessly!
    I'm conparing it to the other script that you wrote. I'm trying to figure out how it knows to grab the info from column A.

    So I'm thinking that it is in this line (RetVal = RetVal & cCell.Offset(ColumnOffset:=-ColRef + 1).Text & ", ")
    I'm assuming that this line takes the current value of RetVal and adds sring of text from an offest position from the existing column. I'm a little stuck understanding this part of the script "Offset(ColumnOffset:=-ColRef + 1)" To me it seems that it would add +1 to the current column offeset?

    Thanks so much, I hope all of that made sense, just trying to learn.

  5. #5
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: How to pull values from a column, and list them in a cell

    Also, I'm going to need six differnt verisions of this
    one that looks for 5's, 4's, 3's, 2's, 1's, and 0's

    So
    Please Login or Register  to view this content.
    And make 6 different ones. Would that be an acceptable way? Thanks!
    Last edited by tray262; 11-08-2012 at 07:55 AM.

  6. #6
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: How to pull values from a column, and list them in a cell

    or could I add something like is?

    Please Login or Register  to view this content.
    Last edited by tray262; 11-08-2012 at 07:56 AM.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Concatenating cell values

    You're getting close. Try this
    Change
    Please Login or Register  to view this content.
    You can enter 5 into your function directly or use a cell reference
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

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

    Re: Concatenating cell values

    This updated code accepts a second parameter: MatchVal
    which can be alphanumeric. The match is NOT case-sensitive...so "Dave" equals "dAvE"

    Please Login or Register  to view this content.
    Does that work for you?

  9. #9
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Concatenating cell values

    WOW WOW WOW!
    Works great.

    So Function ConcatText(rng As Range, numval as String) As String
    Collects my input say B1:B8 and combines it with my "real" value of 5 and makes into one string? Like B1:B85 or it keeps it seperate in the programing? or is this more of setting the var sow rng=a Range and numval=a string of letters, the thing that confusses is the As String at the of that statement.

    I used to do Lisp programming years ago..so I'm really interested.

    Thanks for all of you help!

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

    Re: Concatenating cell values

    Quote Originally Posted by tray262 View Post
    WOW WOW WOW!
    Works great.

    So Function ConcatText(rng As Range, numval as String) As String
    Collects my input say B1:B8 and combines it with my "real" value of 5 and makes into one string? Like B1:B85 or it keeps it seperate in the programing? or is this more of setting the var sow rng=a Range and numval=a string of letters, the thing that confusses is the As String at the of that statement.

    I used to do Lisp programming years ago..so I'm really interested.

    Thanks for all of you help!
    The second parameter in the code posted by ChemistB and by me represents the value you want to find in the referenced range.
    Using the code I posted....
    This: =concattext(B1:B8,5)
    means search the B1:B8 cells for the value 5 and process matching cells.

    Does that help?

  11. #11
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Concatenating cell values

    Yes sir, Thank you so much!

  12. #12
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Concatenating cell values

    I don't want to beat a dead horse but after trying to use is this I'm running into one small problem. But just a question. I'm trying to add one more thing...... I the student name is equal to "0" don't add the name to the list. So I tried adding something and it didn't do anything. I think maybe it's a "but" function or something.

    Please Login or Register  to view this content.
    Thanks again, if there is no way to get it, it's not that big of a deal, just trying to use the same script to do two jobs. I'm determined to learn this.

    Thanks!


    End Function
    Last edited by tray262; 11-08-2012 at 07:56 AM.

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

    Re: Concatenating cell values

    Can you post some sample data that exhibits the problem you want to solve?

  14. #14
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Concatenating cell values

    To post a spreadsheet, Go Advanced > Manage Attachments
    Also, for ease of reading, your code should be in code tags. See #3 of Forum rules for instructions (http://www.excelforum.com/forum-rule...rum-rules.html)

  15. #15
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Concatenating cell values

    This_is what_I_have.jpg So this is what I have. I'm using it the same way as before. The only thing I need to add is if Let's say student 1, has 2 zeros that actually have assignmets in column A. So I want this function to grab the assessment name from column A unless the assessment name is Zero. Hope that make sense.

    Thanks again.

  16. #16
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Concatenating cell values

    Actually I think I got it after a little playing around. I think I'm starting to "get it" Please let me know if you see anything wrong with this. I added the sections in red. I think what I did was I added a 2nd check. So if it checks two things now. Please let me know what ya think. Thanks so much!

    Please Login or Register  to view this content.
    Last edited by tray262; 11-08-2012 at 07:54 AM.

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,052

    Re: Concatenating cell values

    @ tray262...
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  18. #18
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Concatenating cell values

    Sorry about that. I went through and fixed all of my posts with code. Thanks! I'm learning.
    Last edited by tray262; 11-08-2012 at 07:57 AM.

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

    Re: Concatenating cell values

    1) You made a correction that does what you want.
    2) I'd tweak it a bit to make it a little more readable and efficient:
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Concatenating cell values

    Thanks once again! I'm really trying to get the concept. Can you recommend any good book for this type of programming inside of excel. I'm going to try to and attempt to re-code what you've come up with and add a couple things to the function. I'm really having a lot of fun with this. This is what I'm going to try and do.
    Please Login or Register  to view this content.
    Basically the "UpOrOver As String" I'm thinking of making the program either be able to grab the info from the same column or if the data is going the other direction it will grab it from the row. So this is basically going to change if it's going to be a Row offset or a Column offset.

    "WhichPositionToGet" I'm going to make a variable, instead of hardcoding that it is column 1 or row 1, I want to be able to set that in the function. I"m thinking that this will make it a lot more fuctionable for me.

    I'll post some results. I think I've got the bug. Gotta go do some reading.

    Thanks!
    Tray262

  21. #21
    Registered User
    Join Date
    11-02-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Concatenating cell values

    Maybe not. lol.
    Just getting #/Value. Any suggestions.

    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)

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