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
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