how to wrap text

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
hi all,good morning. I hope you can help me please? I have the code, where it copies from spreadsheet and pastes into an email, but I would like to have a wrap text for when its transferred into the email, can you help please?


HTML:
 With Sheets("Handover")
        Set rngDataToEmail = .Range("H4:R" & .Range("H" & Rows.Count).End(xlUp).Row)
    End With

this is the whole code

HTML:
Private Sub CommandButton4_Click()
Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Dim rngDataToEmail As Range

    Set aOutlook = CreateObject("Outlook.Application")
    Set aEmail = aOutlook.CreateItem(0)
    With Sheets("Handover")
        Set rngDataToEmail = .Range("H4:R" & .Range("H" & Rows.Count).End(xlUp).Row)
    End With
    
    aEmail.HTMLBody = "<html>" & _
                    "<p>Hi Paul/Jayne, good afternoon, <p>In day today there was an additional " & Worksheets("Handover").Range("F6").Value & " jobs raised in the system by myself to try and fill the guys up- escalations/sites brought forward. (This does not include the raising of duplicate jobs where work was raised incorrectly or needed to be re-raised due to technical fault)." & Worksheets("Handover").Range("F8").Value & "</p>" & _
                    "<p><u><b>" & Me.TextBox4.Value & "</p></u></b>" & _
                    "<table border=""1"", cellpadding=""18"", style=background:""#a6bbde"" >" & _
                "<tr>" & _
                    "<th>NCMO Issue:</th>" & "<td>" & Worksheets("Handover").Range("C5").Value & "</td>" & "<th>Re-Raised:</th>" & "<td>" & Worksheets("Handover").Range("F5").Value & "</td>" & _
                    "</tr>" & _
                "<tr>" & _
                    "<th>SNR:</th>" & "<td>" & Worksheets("Handover").Range("C6").Value & "</td>" & "<th>Additional Jobs:</th>" & "<td>" & Worksheets("Handover").Range("F6").Value & "</td>" & _
                    "</tr>" & _
                "<tr>" & _
                    "<th>Replans:</th>" & _
                    "<td>" & Worksheets("Handover").Range("C7").Value & "</td>" & "<th>Rebinds:</th>" & "<td>" & Worksheets("Handover").Range("F7").Value & "</td>" & "<th>Outages:</th>" & "<td>" & Worksheets("Handover").Range("c8").Value & "</td>" & _
                    "</tr>" & _
                    "</table>" & _
                "" & _
                "<p><u><b>" & Me.TextBox5.Value & "</p></u></b>" & _
                "<p>" & Me.TextBox1.Value & "</p>" & _
                "<p><u><b>" & Me.TextBox6.Value & "</p></u></b>" & _
                "<p>" & Me.TextBox2.Value & "</p>" & _
                "<p><u><b>" & Me.TextBox7.Value & "</p></u></b>" & _
                "<p>" & Me.TextBox3.Value & "</p>" & RangetoHTML(rngDataToEmail) & _
                "<p>Many Thanks</p>" & _
                "<p>New Connections Team</p>" & _
                "</body></html>"
    
    
    aEmail.Recipients.Add (Worksheets("Email Links").Range("B2").Value)
    aEmail.CC = (Worksheets("Email Links").Range("C2").Value)
    aEmail.BCC = ""
    aEmail.Subject = "" & Range("C1").Value & " " & Range("K1").Value
    aEmail.Display
    
       
End Sub
 
Hi it doesn't wraptext into a1 on issues sheet when I copy the info it wraptext the first empty cell below what I copied over
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi all good morning. Please can you help. I don't understand why the code doesn't wraptext when I copy from handover and paste in to the issues sheet. It doesn't wraptext from a1 and down to the last cell. What it does is wraptext into the first empty cell in the issues sheet.
 
Upvote 0
Hello,

You could test the following :

Code:
Sub TestMacro()
    Sheets("Issues").Select
    Cells.Select
      With Selection
          .WrapText = True
      End With
    Range("A1").Select
End Sub

Hope this will fix your problem ...
 
Upvote 0
Hi. Thanks for your time and help. Will this still copy the data from handover to issues sheet?
 
Upvote 0
No ...

This macro will only wrap all the cells in your Sheet named Issues ...
 
Upvote 0
Hi good morning, I copied the code into my command button but I got an error on the
Code:
Cells.Select
it came up wit a yellow background.
 
Upvote 0
Would you mind posting the entirety of your macro ...
 
Upvote 0
Guessing what is actually in front of your eyes ...

Code:
Private Sub CommandButton2_Click()
Sheets("Handover").Range("H4:R" & Sheets("Handover").Range("H:R").Find("*", , xlValues, , xlByRows, xlPrevious).Row).Copy Sheets("Issues").Range("A1")
Sheets("Issues").Select
    Cells.Select
      With Selection
          .WrapText = True
      End With
    Range("A1").Select
End Sub

HTH
 
Upvote 0
hi thank you for your patience :) the code is put in my commandbutton, and is as follows: and basically all I want I t is copy from handover and paste into issues, and wraptext all the data which a been pasted into the issues sheet, thank again
Code:
Private Sub CommandButton2_Click()
Sheets("Handover").Range("H4:R" & Sheets("Handover").Range("H:R").Find("*", , xlValues, , xlByRows, xlPrevious).Row).Copy Sheets("Issues").Range("A1")
    Sheets("Issues").Select
    Cells.Select
      With Selection
          .WrapText = True
      End With
    Range("A1").Select
End Sub
 
Upvote 0
Well ...

Can you comment on the differences you find ... between Message #28 and Message #29 ... ?
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top