[ dudovt @ 05.09.2012. 12:11 ] @
Pozdrav svima

Imam jednu molbu ako mi netko može pomoći
Kroz textbox upisujem brojeve naravno trebaju mi 2 decimale ali kad upišem 50,14 sa zarezom sprema mi broj kao text.

E sad pošto se to radi o bazi i jako puno brojeva za upisivanje nemože se ručno pretvarati ,makro isto tako koji označi posle unosa sve podatke i pretvara u broj mi ne odgovara.
Dali ima koje drugo rješenje poput da upišeš broj sa točkom ili zarezom uvjek snimi kao 30,20 a da nebude broj spremljen kao text

Ali kad u textbox upisavam sa točkom onda je ok.

Code:
Private Sub CommandButton1_Click()

Dim lRow As Long
Dim List1 As Worksheet
Set List1 = Worksheets("List1")
lRow = List1.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(1, 0).Row
With List1

  .Cells(lRow, 1).Value = Me.Te.Value
  End With
TextBox1 = ""
End Sub




[ neptuncokg @ 05.09.2012. 13:19 ] @
Za pretvaranje zareza u tacku, dovoljno je iskoristiti funkciju Replace u codu za CommandButton. Pogledaj prilog.
Pozdrav


[ dudovt @ 05.09.2012. 13:47 ] @
hvala na pomći

samo još jedno pitanje s obzirom da imam 20 texbox-ova u form-u dali moram za svaki pisati code ili se može samo jedan za svih 20
[ neptuncokg @ 05.09.2012. 14:05 ] @
Zamena zareza za tacku - Replace funkcija je smestena u dogadjaju CommandButton1_Click. Dakle, nije ni u jednom dogadjaju TextBox-a.
Zbog toga mi tvoje pitanje nije bas najjasnije. Mozda bi najbolje bilo da postavis ceo dokumenat, pa da vidimo...
Ovako napamet, pretpostavljam da iz 20 txt-a unosis podatke u 20 kolona-celija ...? U tom slucaju, u onom istom codu ti treba 20 linija za 20 Replace-a.
Pozdrav
[ dudovt @ 05.09.2012. 14:41 ] @
Da dobro ste pretpostavili
evo macro jer mi je teško sad izvaditi samo taj dio

Code:
Private Sub CommandButton4_Click()
Dim lRow As Long
Dim lNA As Long
Dim baza As Worksheet
Dim bazaura As Worksheet
Dim bazakpi As Worksheet
Set baza = Worksheets("baza")
Set bazakpi = Worksheets("bazakpi")
Set bazaura = Worksheets("bazaura")


lRow = baza.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(1, 0).Row

  
lNA = Me.cboNA.ListIndex


If Trim(Me.cboNA.Value) = "" Then
  Me.cboNA.SetFocus
  MsgBox "Please enter a part number"
  Exit Sub
End If


With baza
If CheckBox3 = True Then
        .Cells(lRow, 5).Value = "Da"
    End If
If CheckBox4 = True Then
        .Cells(lRow, 5).Value = "Ne"
    End If
If CheckBox5 = True Then
        .Cells(lRow, 6).Value = "Gotovina"
    End If
If CheckBox6 = True Then
        .Cells(lRow, 6).Value = "Žiro račun"
    End If
If CheckBox7 = True Then
        .Cells(lRow, 6).Value = "Čekovi"
    End If
If CheckBox8 = True Then
        .Cells(lRow, 6).Value = "U naravi"
    End If
  .Cells(lRow, 1).FormulaR1C1 = "=IF(RC[1]&RC[2]&RC[3]<>"""",OFFSET(RC,-1,0)+1,"""")"
  .Cells(lRow, 23).Value = Me.txtRB.Value
  .Cells(lRow, 2).Value = Me.txtTRO.Value
  .Cells(lRow, 3).Value = Me.txtTE.Value
  .Cells(lRow, 4).Value = Me.txtDAPL.Value
  .Cells(lRow, 7).Value = Me.txtBR.Value
  .Cells(lRow, 8).Value = Me.txtDA.Value
  .Cells(lRow, 9).Value = Me.cboNA.Value
  .Cells(lRow, 10).Value = Me.cboNA.List(lNA, 1)
  .Cells(lRow, 11).Value = Me.txtNU.Value
  .Cells(lRow, 12).Value = Me.txtDE.Value
  .Cells(lRow, 13).Value = Me.txtDV.Value
  .Cells(lRow, 14).Value = Me.txtDVT.Value
  .Cells(lRow, 15).Value = Me.txtUK.Value
  .Cells(lRow, 16).Value = Val(txtDADE.Text) + Val(txtNEDE.Text) + Val(txtDADV.Text) + Val(txtNEDV.Text) + Val(txtDADVT.Text) + Val(txtNEDVT.Text)
  .Cells(lRow, 17).Value = Me.txtDADE.Value
  .Cells(lRow, 18).Value = Me.txtNEDE.Value
  .Cells(lRow, 19).Value = Me.txtDADV.Value
  .Cells(lRow, 20).Value = Me.txtNEDV.Value
  .Cells(lRow, 21).Value = Me.txtDADVT.Value
  .Cells(lRow, 22).Value = Me.txtNEDVT.Value
 End With
 
lRow = bazaura.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(1, 0).Row
 With bazaura
If CheckBox3 = True Then
        .Cells(lRow, 5).Value = "Da"
    End If
If CheckBox4 = True Then
        .Cells(lRow, 5).Value = "Ne"
    End If
If CheckBox5 = True Then
        .Cells(lRow, 6).Value = "Gotovina"
    End If
If CheckBox6 = True Then
        .Cells(lRow, 6).Value = "Žiro račun"
    End If
If CheckBox7 = True Then
        .Cells(lRow, 6).Value = "Čekovi"
    End If
If CheckBox8 = True Then
        .Cells(lRow, 6).Value = "U naravi"
    End If
  .Cells(lRow, 1).FormulaR1C1 = "=IF(RC[1]&RC[2]&RC[3]<>"""",OFFSET(RC,-1,0)+1,"""")"
  .Cells(lRow, 23).Value = Me.txtRB.Value
  .Cells(lRow, 2).Value = Me.txtTRO.Value
  .Cells(lRow, 3).Value = Me.txtTE.Value
  .Cells(lRow, 4).Value = Me.txtDAPL.Value
  .Cells(lRow, 7).Value = Me.txtBR.Value
  .Cells(lRow, 8).Value = Me.txtDA.Value
  .Cells(lRow, 9).Value = Me.cboNA.Value
  .Cells(lRow, 10).Value = Me.cboNA.List(lNA, 1)
  .Cells(lRow, 11).Value = Me.txtNU.Value
  .Cells(lRow, 12).Value = Me.txtDE.Value
  .Cells(lRow, 13).Value = Me.txtDV.Value
  .Cells(lRow, 14).Value = Me.txtDVT.Value
  .Cells(lRow, 15).Value = Me.txtUK.Value
  .Cells(lRow, 16).Value = Val(txtDADE.Text) + Val(txtNEDE.Text) + Val(txtDADV.Text) + Val(txtNEDV.Text) + Val(txtDADVT.Text) + Val(txtNEDVT.Text)
  .Cells(lRow, 17).Value = Me.txtDADE.Value
  .Cells(lRow, 18).Value = Me.txtNEDE.Value
  .Cells(lRow, 19).Value = Me.txtDADV.Value
  .Cells(lRow, 20).Value = Me.txtNEDV.Value
  .Cells(lRow, 21).Value = Me.txtDADVT.Value
  .Cells(lRow, 22).Value = Me.txtNEDVT.Value
  End With

lRow = bazakpi.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(1, 0).Row
 With bazakpi
  .Cells(lRow, 1).FormulaR1C1 = "=IF(RC[1]&RC[2]&RC[3]<>"""",OFFSET(RC,-1,0)+1,"""")"
  .Cells(lRow, 2).Value = Me.txtDA.Value
  .Cells(lRow, 3).Value = Me.txtTE.Value
  .Cells(lRow, 4).Value = Me.txtBR.Value
  .Cells(lRow, 10).FormulaR1C1 = "=IF(RC[11]=""Gotovina"",RC[10],"""")"
  .Cells(lRow, 11).FormulaR1C1 = "=IF(RC[10]=""Žiro račun"",RC[9],"""")"
  .Cells(lRow, 12).FormulaR1C1 = "=IF(RC[9]=""U naravi"",RC[8],"""")"
  .Cells(lRow, 13).Value = Val(txtDADE.Text) + Val(txtNEDE.Text) + Val(txtDADV.Text) + Val(txtNEDV.Text) + Val(txtDADVT.Text) + Val(txtNEDVT.Text)
  .Cells(lRow, 15).FormulaR1C1 = "=SUM(RC[5]-RC[-1]-RC[-2])"
  .Cells(lRow, 20).Value = Me.txtUK.Value
  If CheckBox5 = True Then
        .Cells(lRow, 21).Value = "Gotovina"
    End If
If CheckBox6 = True Then
        .Cells(lRow, 21).Value = "Žiro račun"
    End If
If CheckBox7 = True Then
        .Cells(lRow, 21).Value = "Čekovi"
    End If
If CheckBox8 = True Then
        .Cells(lRow, 21).Value = "U naravi"
    End If
  End With
  
lRow = bazaura.Cells(Rows.Count, 1) _
  .End(xlUp).Offset(1, 0).Row

    frmUra.ListBox1.TopIndex = frmUra.ListBox1.ListIndex
    frmUra.ListBox1.ListIndex = -1
    frmUra.ListBox2.TopIndex = frmUra.ListBox2.ListIndex
    frmUra.ListBox2.ListIndex = -1
    
    Unload Me
End Sub
[ neptuncokg @ 05.09.2012. 15:05 ] @
Nemoguce je razumeti ovoliki macro bez primera. Ukoliko je moja pretpostavka tacna (20 txt-a u 20 kolona), evo primera sa 3 textboxa u 3 kolone,
pa ti prilagodi svojim potrebama. Pozdrav
[ dudovt @ 05.09.2012. 16:07 ] @
Ma nije mi problem za svaki texbox pisati code jednostavnije nego svaki put označiti sve podatke u bazi i pretvoriti u broj

Hvala na pomoći