First change the base line to something like this
BaseString = "Your vehicle selection of {VEHSEL} indicates you should have " & _ "between {nTYRE1} and {nTYRE2} tires. However, you have entered " & _ "{nTotTYRE} tires for this vehicle. Please update the record " & _ "accordingly."
If you notice that you have special Keywords , for example
VEHSEL - Vehicle Selection nTYRE1 - Lowest selection of tires nTYRE2 - Highest selection of tires nTotTYRE - Total tires selected
Once you pick up the values ββfrom the set of spreadnets, just use REPLACE
to replace the above Keywords with the corresponding values
So your code will look like
Option Explicit Sub Sample() Dim lVSell As Long, lT1 As Long, lT2 As Long, ltotT As Long Dim lRowID As Long lRowID = 5 With Sheets("Sheet1") lVSell = .Range("A" & lRowID).Value lT1 = .Range("B" & lRowID).Value lT2 = .Range("C" & lRowID).Value ltotT = .Range("D" & lRowID).Value Debug.Print ShowMsg(lRowID, lVSell, lT1, lT2, ltotT) End With End Sub Function ShowMsg(ByVal RowID As Integer, ByVal VSel As Long, _ ByVal T1 As Long, ByVal T2 As Long, ByVal totT As Long) As String Dim BaseString As String BaseString = "Your vehicle selection of {VEHSEL} indicates you should have " & _ "between {nTYRE1} and {nTYRE2} tires. However, you have entered " & _ "{nTotTYRE} tires for this vehicle. Please update the record " & _ "accordingly." BaseString = Replace(BaseString, "VEHSEL", VSel) BaseString = Replace(BaseString, "nTYRE1", T1) BaseString = Replace(BaseString, "nTYRE2", T2) BaseString = Replace(BaseString, "nTotTYRE", totT) ShowMsg = BaseString End Function
I assume the values ββare stored in Sheet 1 from the range A5 to D5.
EDIT
Snapshot
NTN