Email Data as Percentage 0.00%

tlaltmey

New Member
Joined
Nov 10, 2021
Messages
20
Office Version
  1. 365
  2. 2019
Hello, I currently have the following code:

VBA Code:
Sub Submit()

Application.DisplayAlerts = False

Dim path As String
Dim filename1 As String
Dim emailApplication As Object
Dim emailItem As Object
Dim lastRow As Long
Dim mainWB As Workbook
Dim wsDest As Worksheet
Dim wsCopy As Worksheet

Set mainWB = ActiveWorkbook
Set wsCopy = mainWB.Worksheets("Sheet1")

lastRow = Cells(Rows.Count, 3).End(xlUp).Row

 ChDrive "F"
 ChDir "Path1"
 filename1 = "name"
 ActiveWorkbook.SaveAs Filename:=path & filename1, FileFormat:=52
   
    Set emailApplication = CreateObject("Outlook.Application")
    Set emailItem = emailApplication.CreateItem(0)
               
                    emailItem.to = "email@email.com"
                    emailItem.Subject = "subject"

                    emailItem.Body = "Text " & wsCopy.Range("D" & lastRow).Value

                    emailItem.Attachments.Add ActiveWorkbook.FullName

                    emailItem.Send
                   
                    Set emailItem = Nothing
                    Set emailApplication = Nothing
                   
                    Application.ScreenUpdating = False
                    Application.DisplayAlerts = False
                    Application.AutomationSecurity = msoAutomationSecurityForceDisable
                    Application.AskToUpdateLinks = False
                   
                    Application.DisplayAlerts = True
                   
                    ActiveWorkbook.Close True
                   
End Sub

This finds the last populated cell in column C and outputs an email to an individual showing them what the data is on that row for column D. At the moment, it is emailing as an integer and I would like it to be sent as a percentage such as 0.00%.

IE: the emailitem.Body is sent as Text 1 for 100% when instead it should be sent as Text 100%.

Likewise, if it is 98% it is currently being sent as Text .98 instead of Text 98%.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Change this line:
VBA Code:
emailItem.Body = "Text " & wsCopy.Range("D" & lastRow).Value
to:
VBA Code:
emailItem.Body = "Text " & Format(wsCopy.Range("D" & lastRow).Value, "0%")
 
Upvote 0
Solution

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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