Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 th product. For example: I have a double-variable with content: 21.234,23 tha represents the amount of liters sold of that product and string-variable with content “L” that represents the Unit o Measurement of the sold product. Different UOM’s could appear such a “P” (pieces), “L” (liters) or M2 (square meters). The two variables together should mean that I sold 21.234 liters of th product. When I look at the cell I should see: 21.234 L , but when I click o the cell it should just appear as a number in order to be able to mak calculation. I have tried this in Exel with “Format Cells”, tab “Number”, choic “Custom” and that works out fine. But I should achieve the same result by using VBA-code because I hav thousands of lines to process in that way. I have been trying my as 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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Change 3 letter text string to a number string | Excel Discussion (Misc queries) | |||
How do I string formulas together in Excel to display variables | New Users to Excel | |||
String variables | New Users to Excel | |||
Conditional formatting for lowest number in a string | Excel Worksheet Functions | |||
String Variables | Excel Programming |