Change value to number and percent in a sentence

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
431
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
How can i change the values in a sentence below to number then next value as percent?

VBA Code:
    With ws
        .Range("A46:Q46").Value = ""
        .Range("A46") = "Yesterday we did on " & Rng1.NumberFormat = "2" & " with a GP of " & Rng2.Value = FormatPercent & "."
        .Range("A47:Q47").Value = ""
        .Range("A47") = "That’s made up of " & Rng3 & " orders with the average value of " & Rng4.NumberFormat = "0" & "."
End With

Main code below

VBA Code:
Option Explicit

Sub YesterdaysDailyMailFigures()

    Dim wb     As Workbook
    Dim ws     As Worksheet
    Dim dmwb   As Workbook
    Dim dmws   As Worksheet
    Dim swb    As Workbook
    Dim sws    As Worksheet
    Dim Rng1   As Range, Rng2 As Range, Rng3 As Range, Rng4 As Range

    Set wb = Workbooks("MyPersonal.xlsb")
    Set ws = wb.Worksheets("DailyMail")
    Set swb = ActiveWorkbook
    Set sws = swb.Worksheets("Sheet")
    
    With sws
        Set Rng1 = .Range("A2")
        Set Rng2 = .Range("B2")
        Set Rng3 = .Range("C2")
        Set Rng4 = .Range("D2")
    End With
    
    With ws
        .Range("A46:Q46").Value = ""
        .Range("A46") = "Yesterday we did on " & Rng1.NumberFormat = "2" & " with a GP of " & Rng2.Value = FormatPercent & "."
        .Range("A47:Q47").Value = ""
        .Range("A47") = "That’s made up of " & Rng3 & " orders with the average value of " & Rng4.NumberFormat = "0" & "."
End With

End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Please show us what the value on the sheet looks like, and what you want your desired result to look like.

Typically, you would use the FORMAT function in VBA, something like this:
VBA Code:
... & FORMAT(Rng4, "0%") & ...
 
Upvote 0
Solution
Please show us what the value on the sheet looks like, and what you want your desired result to look like.

Typically, you would use the FORMAT function in VBA, something like this:
VBA Code:
... & FORMAT(Rng4, "0%") & ...
Thanks that works fine
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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