Thousand and decimal separator in a VBA excel

269 Views Asked by At

I have an inventory to manage the stock in the lab with 2 sections: one related to the Order and one related to the used parts, but I have a couple of issues:

  1. In the Userform that I designed to track the order and the used parts, the operation on the last cell that is managing the TOTAL by multiplication with quantity and the price of the single part NOT showing me the decimal separator.

    UserForm with decimal separator issue

    Here the code for one text box to manage the quantity and have the total in the last text box:

    Private Sub cmdReceiving_Click()    
        Dim X As Integer
        Dim nextrow As Range
        Dim DateCus As Range
    
        On Error GoTo cmdReceiving_Click_Error
    
        Me.Arec6.Value = Format(Me.Arec6.Value, "€##,###.00")
        Me.Brec6.Value = Format(Me.Brec6.Value, "€##,###.00")
        Me.Crec6.Value = Format(Me.Crec6.Value, "€##,###.00")
        Me.Drec6.Value = Format(Me.Drec6.Value, "€##,###.00")
        Me.Erec6.Value = Format(Me.Erec6.Value, "€##,###.00")
        Me.Frec6.Value = Format(Me.Frec6.Value, "€##,###.00")
        Me.Grec6.Value = Format(Me.Grec6.Value, "€##,###.00")
        Me.Hrec6.Value = Format(Me.Hrec6.Value, "€##,###.00")
        Me.Irec6.Value = Format(Me.Irec6.Value, "€##,###.00")
        Me.Jrec6.Value = Format(Me.Jrec6.Value, "€##,###.00")
        Me.Krec6.Value = Format(Me.Krec6.Value, "€##,###.00")
    

    The following part of code is referred to Arec3 that is the quantity cell (Qty) in the UserForm. This is going to read in an inventory sheet and get the data from it doing the math

    Private Sub Arec3_Change()
        On Error Resume Next
        Me.Arec2.RowSource = ""
        Me.Arec4 = Application.WorksheetFunction.VLookup(Me.Arec2, Sheet5.Range("Data"), 2, 0)
        Me.Arec5 = Application.WorksheetFunction.VLookup(Me.Arec2, Sheet5.Range("Data"), 3, 0)
        If Me.Arec3.Value > "" Then Me.Arec6 = Me.Arec3.Value * Me.Arec5.Value
    
        On Error GoTo 0
    
    End Sub
    
  2. The other issue is about the formatting in the Excel sheet regarding the stock. Once I filled up the UserForm with my info, all these info are stored in an excel sheet but the € column related to the single cost and the Total are always giving me not proper formatting. Even if I select from File->Options->Advanced->"," for thousand and "." for decimal I still have the result in the second picture:

    Formatting thousand/decimal excel sheet

Could someone help me with that? I really don't understand what's wrong.

0

There are 0 best solutions below