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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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