2 Replies - 934 Views - Last Post: 06 August 2012 - 07:49 AM Rate Topic: -----

#1 jram15  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 19-May 11

BREAK UP OF NMBERS IN EXCEL

Posted 02 August 2012 - 11:13 AM

dear sir,

I have a text box txtdye1qty.Text having numbers as 100.123456
it is roughly 100 kilos and 123 gram and 456 milligram.

I want to export to excel and want to display 100.123 in one cell for example A1 and 456 in A2.

Private Sub cmddyechem_Click()
 
    
  Dim oExcel As Object
    Dim oBook As Object
    Dim oSheet As Object
    Set oExcel = CreateObject("Excel.Application")
    Set oBook = oExcel.Workbooks.Add
    Set oSheet = oExcel.Worksheets.Add
    
  'PAGE BREAK UPS

   With oExcel.ActiveSheet
   oExcel.ActiveSheet.PageSetup.Zoom = False
   oExcel.ActiveSheet.PageSetup.FitToPagesTall = 1
   oExcel.ActiveSheet.PageSetup.FitToPagesWide = 1
  End With



'Rem Make Excel Visible

   oExcel.Visible = True



 
   oBook.Worksheets(1).Range("A1") = txtdye1qty.Text
   oBook.Worksheets(1).Range("A1").HorizontalAlignment = myVAlignCenter
   oBook.Worksheets(1).Range("A1").Font.Size = 25
   oBook.Worksheets(1).Range("A1").Font.Bold = True
   oBook.Worksheets(1).Range("A1").Font.Name = "Verdana"
   With oExcel.ActiveSheet
   oExcel.ActiveSheet.Cells(1, 1).NumberFormat = "0.000"
   End With
   


END SUB



HOW TO DISPLAY REST OF THE THREE NUMBERS IN A2
PLEASE HELP ME


WITH ADVANCE THANKS

S.JEYARAMAN

This post has been edited by macosxnerd101: 02 August 2012 - 11:42 AM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: BREAK UP OF NMBERS IN EXCEL

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 271
  • View blog
  • Posts: 1,633
  • Joined: 26-March 09

Re: BREAK UP OF NMBERS IN EXCEL

Posted 02 August 2012 - 01:45 PM

If your numbers always have 6 decimal places, then you can use the RIGHT$ function to extract the last 3 digits from your string held in the textbox.
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is online

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 549
  • View blog
  • Posts: 2,911
  • Joined: 19-May 09

Re: BREAK UP OF NMBERS IN EXCEL

Posted 06 August 2012 - 07:49 AM

Another option using maths instead of string manipulation, to get the mg value: multiply value by 1000, and subtract int(value) from value:

100.123456 * 1000 = 100123.456
int(100123.456) = 100123
100123.456 = 100123 = .456
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1