+ Reply to Thread
Results 1 to 12 of 12

Wrap Text without Wrapping Text

Hybrid View

  1. #1
    Registered User
    Join Date
    06-02-2013
    Location
    unsalab dunciad
    MS-Off Ver
    Excel
    Posts
    5

    Cool Wrap Text without Wrapping Text

    I have a need to "wrap text" without using the wrap text function. My goal is if cell x contains > 15 characters the 1st 15 characters stay there and the next 15 characters get populated in cell y. I've searched long and hard through the forums with no success. I can limit the number in each cell and everyone keeps telling me to just merge the cells and use wrap text but that doesn't work for what I'm using it for. Please assist.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Wrap Text without Wrapping Text

    Some idea.

    If Len(Range("A")) > 15 Then Range("A").WrapText = True

  3. #3
    Registered User
    Join Date
    06-02-2013
    Location
    unsalab dunciad
    MS-Off Ver
    Excel
    Posts
    5

    Re: Wrap Text without Wrapping Text

    Thank you for responding, unfortunately I actually need the text to come out of the one cell and be set as the value in the new cell. For instance: Cell X "The big brown dog" Cell Y "jumps over the fence". When you use the wrap text feature Cell X has a value of: "The big brown dog jumps over the fence"

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Wrap Text without Wrapping Text

    In that case you need &, or join functions.

    Range("A1") = Range("A1") & "" & Range("B1")

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Wrap Text without Wrapping Text

    Manthux,

    Try something like this:

    Sub manthux()
    
    Dim str As String
    Dim num As Integer
    Dim rng As Range
    
    Set rng = ActiveCell
    num = Len(rng) - 15
    str = rng.Value
    
        If Len(rng) > 15 Then
            rng.Offset(1, 0).Value = Right(str, num)
            rng.Value = Left(str, 15)
        End If
    
    End Sub
    Its not set up for with an event handler so you'll have to run it with a short cut key or something like that. Its also not set up to loop through the whole spreadsheet (although it could be set up that way). Its only set up to run on the cell you have selected.

  6. #6
    Registered User
    Join Date
    06-02-2013
    Location
    unsalab dunciad
    MS-Off Ver
    Excel
    Posts
    5

    Re: Wrap Text without Wrapping Text

    I love where your head is at but it doesn't move the remaining characters to another row

  7. #7
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655
    Rng.offset(1,0).value = does. At least it did just fine in my test book
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  8. #8
    Registered User
    Join Date
    06-02-2013
    Location
    unsalab dunciad
    MS-Off Ver
    Excel
    Posts
    5

    Re: Wrap Text without Wrapping Text

    I think the problem is because I am using a VLookup("X") operation, the cell that is populated with the info is just carrying it over from the original cell, any ideas?

  9. #9
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Wrap Text without Wrapping Text

    If that code was added to something bigger maybe you should post an example workbook so we can see it in context.

  10. #10
    Registered User
    Join Date
    06-02-2013
    Location
    unsalab dunciad
    MS-Off Ver
    Excel
    Posts
    5

    Re: Wrap Text without Wrapping Text

    Ok the goal is: User enters information in column P - information is than populated in a different column (column W) when the user puts an "X" in the first column of that row. when the information is populated in the second column, if it is > 44 characters I need the remaining characters to be dropped into the next cell down (different row) I currently have the information being populated into the cell I need when an X is placed but the > 44 character operation isn't working

    =VLookup("X",$A$24:$T$1000,16) displays the correct info, but if this value is > 44 then characters 45 plus should be in the row below

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Wrap Text without Wrapping Text

    you could use 2 vlookups
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Wrap Text without Wrapping Text

    W1=left(VLookup("X",$A$24:$T$1000,16),44)
    W2=mid(VLookup("X",$A$24:$T$1000,16),45,200)



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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