View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Number Formatting with string variables

Sub AABBCC()
Dim strUnits As String
Dim dblVal As Double
Dim cell As Range
Set cell = Range("B9")
strUnits = "L"
dblVal = 21234.23
cell.NumberFormat = "#,###.00" & " " & strUnits
cell.Value = dblVal

End Sub


--
Regards,
Tom Ogilvy



"KempensBoerke " wrote in
message ...
Hi

I want to achieve a number format with a decimal number in the cell,
and behind this number you can find the Unit of Measurement of the
product.

For example: I have a double-variable with content: 21.234,23 that
represents the amount of liters sold of that product and a
string-variable with content "L" that represents the Unit of
Measurement of the sold product. Different UOM's could appear such as
"P" (pieces), "L" (liters) or M2 (square meters).

The two variables together should mean that I sold 21.234 liters of the
product.

When I look at the cell I should see: 21.234 L , but when I click on
the cell it should just appear as a number in order to be able to make
calculation.

I have tried this in Exel with "Format Cells", tab "Number", choice
"Custom" and that works out fine.

But I should achieve the same result by using VBA-code because I have
thousands of lines to process in that way. I have been trying my ass
off with the bracket-things and could find it. :(

Thank you in advance. ;)

Boerke.

p.s. my apologies if my English is miserable.


---
Message posted from http://www.ExcelForum.com/