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