View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jake Marx[_3_] Jake Marx[_3_] is offline
external usenet poster
 
Posts: 860
Default Pad with leading zeros?

43fan wrote:
Thanks for the quick reply, but yes, something VBA related. I'm
printing a heading on a report that will be the concatenation of
several fields like I said, and one of those fields needs to have
leading zeroes.

I'm wondering though, could I use something like this?

newvar = A + B + str(C/1000)?


When concatenating Strings, you should use the & operator. The Str function
will work, but Format gives you more control over the output.

As Mark suggested, you can use the Format function:

Dim sNewVar As String

sNewVar = Range("A1").Value & Range("A2").Value & _
Format$(Range("A3").Value/1000, ".000")

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]