Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Number Formatting with string variables

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   Report Post  
Posted to microsoft.public.excel.programming
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/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
How do I string formulas together in Excel to display variables DavidB New Users to Excel 19 October 10th 06 09:44 AM
String variables John New Users to Excel 3 July 16th 06 09:08 PM
Conditional formatting for lowest number in a string Phil Lewis Excel Worksheet Functions 5 March 23rd 06 09:44 PM
String Variables [email protected] Excel Programming 1 August 30th 03 07:28 AM


All times are GMT +1. The time now is 07:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"