View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
moon[_5_] moon[_5_] is offline
external usenet poster
 
Posts: 40
Default Label = whole number - How do I set this?


Format works, but 125,5 is changed to 126.
That's the same as Round( Worksheets("Data").Range("j20").Value, 0 )
He asked for 125.


Label2.Caption = Left(LTrim(Str(Worksheets("Data").Range("j20").Val ue)),
InStr(1, LTrim(Str(Worksheets("Data").Range("j20").Value)), ".",
vbTextCompare) - 1)

will give 125.




"Dan Hatola" schreef in bericht
...
On your spreadsheet you have probably formatted the cell to show whole
numbers, but that doesn't actually change the cell value.

You can format in VBA as well before you display the value. Try:
Label2.Caption = Format(Worksheets("Data").Range("j20").Value,"#")

Note: This is also a format and will not change the actual value.

Hope this helps,
Dan

"Bafa" wrote:


Private Sub UserForm_Initialize()
Label2.Caption = Worksheets("Data").Range("j20").Value
End Sub

I am using this to draw calculated data from my worksheet and paste
into my UserForm. I set my work sheet cell J20 up to use whole numbers
only, but when my UserForm calls the data up it is still being told
decimal values. Instead of 125.5 showing up in my user form I want to
see just 125 How can I do this please?

Also any suggested reading web sites for someone just wetting their
feet in this?


--
Bafa
------------------------------------------------------------------------
Bafa's Profile:
http://www.excelforum.com/member.php...o&userid=37748
View this thread:
http://www.excelforum.com/showthread...hreadid=573620