Hi there,
I'm moving forward in creating an userform which retrieves data from a worksheet and displays the results in some textboxes.
So far everything works fine, now I need to complete the last step: the user via a combo box selects an item, inserts the quantity and by clicking a button I have to 'send' the selected values to another worksheet in given cells.
I set up this code
Private Sub InserisciArticolo_Click()
Worksheets("prova_userform").Select
Dim ItemNo As Long
Dim Row As Long
Row = 3
ItemNo = Row - 2
Cells(Row, 1).Value = ItemNo 'indice progressivo items
Cells(Row, 2).Value = CodiceProdotto 'codice prodotto
Cells(Row, 4).Value = sceltaArredi.Value 'descrizione articolo d'arredo in italiano
Cells(Row, 5).Value = Qty ' quantità inserita
Cells(Row, 6).Value = VolumeProdotto 'volume dell'articolo
Cells(Row, 7).Value = PrezzoProdotto 'prezzo dell'articolo
'Cells(Row, 7).Style = "Currency" 'formatta cella come valuta
Cells(Row, 7).NumberFormat = "€#,##0.##" 'formatta cella come valuta euro
Cells(Row, 8).Formula = "=(Cells(Row, 6)) * (Cells(Row, 5))" 'volume totale
Cells(Row, 9).Formula = "=(Cells(Row, 7)) * (Cells(Row, 5))" 'prezzo totale
Cells(Row, 9).Style = "Currency" 'formatta cella come valuta
This code works and place all the data in the form in the right cells, but I'm having a few troubles in set the value for the last two string listed as a formula.
My goal is to set the value as a formula like =E3*F3 which actually returns me the extended volume multiplying the unit volume by the quantity.
Is maybe better to achieve the result by combining simple Excel formula and import via VBA only the unit values?
Either cases I'm getting a 2nd problem: how to format imported VBA data to currency.
Above I used the property Style of the object Cells, referencing which cell I want to format, but even though the code works fine (debug ok), my cells actually wont format.
Of course, I think I don't define well the cells, because the cells formulas as well won't return me the results..
I attach a couple of self-explaining images.
Next step would be increase the row by 1 as I inserted the values, so that next selected item in my userform will be placed below the 1st row.
thanks again for your help guys 
P.
Bookmarks