Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate in VBA - Metric Imperial Conversion 1

Status
Not open for further replies.

TortolaChris

Technical User
Jan 13, 2002
56
GB
I am trying to write a VBA metric conversion function in Excel but am struggling with using Concatenate as a worksheet function within the code.
What I have so far is:
Function MetImp(Metric)
Prime = Metric / 25.4
Feet = WorksheetFunction.RoundDown(Prime / 12, 0)
Inch = WorksheetFunction.Round(Prime - (12 * Feet), 1)

and what I would like to end with is:

MetImp = WorksheetFunction.Concatenate(Feet,"' ",Inch,"''")

End Function

but it won't work!

It doesn't seem to like me writing Feet&"' "&Inch"''" either.

Has anyone got any ideas? I am really new to VBA so please don't be afraid of stating the obvious!

Thanks
Chris
 
How about
Feet & "' " & Inch [red]&[/red] "''" either

For clarity you could use Feet & Chr(39) & Inch & Chr(43).

A.C.
 
Thank you so much! I had tried for so long to get it right and was on the point of throwing in the towel on the formula and having a rum and coke - when I'd promised myself a day off the stuff!
Thanks again
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top