title: How to retain the NumberFormat when converting numbers to a string in Excel VBA?
body: <p>Consider the following code:</p>
  
  <pre><code>Sub CombineNumbersToASTring()
  
  ' force Excel to show two decimals, even when there are trailing zeros
  Range("A1", "B1").NumberFormat = "0.00"
  
  ' give some values to the previously mentioned cells
  Cells(1, 1).Value = 0.1
  Cells(1, 2).Value = 0.2
  
  ' combine the previous two values into one cell
  Cells(1, 3).Value = "(" &amp; Cells(1, 1).Value &amp; ", " &amp; Cells(1, 2).Value &amp; ")"
  
  End Sub
  </code></pre>
  
  <p>The result is erroneously</p>
  
  <p>0.10    0.20    (0.1, 0.2)</p>
  
  <p>although it should be</p>
  
  <p>0.10    0.20    (0.10, 0.20)</p>
  
  <p>So, how could I retain the NumberFormat when converting to a string in Excel VBA? The CStr method seemed not to work.</p>
  
  <p>(Edit: I shall also add here that in my larger code the number of decimal places is changing from cell to another, so the decimal places can't be known from beforehand when writing the VBA code.)</p>