Templating Engine Carriage Return

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
Hi there, trying to make a templating engine udf function to handle string replacement but I can't seem to figure out how to handle carriage returns. I want to insert a carriage return when my engine processes <cr> string.

Here's my code. The red line is my attempt to do the carriage return but it doesn't do it. It just ignores it. Help please? Thanks
Code:
Function proceng(rawstr As String)
Application.Volatile
mtypesel = Sheet1.Range("mtypesel")
refnum = Sheet1.Range("refnum")
vtypesel = Sheet1.Range("vtypesel")
shipzip = Sheet1.Range("shipzip")
destzip = Sheet1.Range("destzip")
orgcity = Sheet1.Range("orgcity")
destcity = Sheet1.Range("destcity")
orgport = Sheet1.Range("orgport")
destport = Sheet1.Range("destport")
orgcnty = UCase(Sheet1.Range("orgcnty"))
destcnty = UCase(Sheet1.Range("destcnty"))
template = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(rawstr, "<ref #>", refnum), "<truck size>", vtypesel), "<org zip>", shipzip), "<dest zip>", destzip), "<org city>", orgcity), "<org port>", orgport), "<dest port>", destport), "<org cnty>", orgcnty), "<dest cnty>", destcnty), "<mode>", mtypesel)
[COLOR=#ff0000]template = Replace(template, "<cr>", Chr(10))[/COLOR]
proceng = template
End Function
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

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