kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
This code is what I am using to get the accumulated balance.
The one here is used to update data.
I have this code that I am using to update my database.
Column A contain IDs and one id could exist multiple times.
The ID field is the tb1. I have been finding the accumilated balance then add it to the new record I add thhrough the update process.
My goal here is to place only on data for balance for each ID. See the image for clarity.
I need a way to achieve this.
I sort data by date first then Account number all in ascending order.
Thanks for your help.
Code:
Sub Get_bal()
Dim acc_num As Range, lr&
Dim db As Worksheet, val_due#, pay_mad#
Set db = Sheets("Database")
lr = db.Cells(Rows.Count, "A").End(xlUp).Row
If lr < 4 Then lr = 4
val_due = 0
pay_mad = 0
With frmData
val_due = Application.SumIfs(db.Range("H4:H" & lr), db.Range("A4:A" & lr), .tb1.Text)
pay_mad = Application.SumIfs(db.Range("I4:I" & lr), db.Range("A4:A" & lr), .tb1.Text)
Select Case .cmb_load_invoice
Case ""
.tb10 = val(.tb8) - val(.tb9)
Case Else
.tb10 = (val_due - pay_mad) + (val(.tb8) - val(.tb9))
End Select
End With
End Sub
The one here is used to update data.
Code:
Set lrRng = db.Cells(Rows.Count, db.[A4].Column).End(xlUp).Offset(1)
lrRng = tb1.Text
For i = 1 To 9
Select Case i
Case 1
If tb2 <> "" Then
lrRng.Offset(, i) = CDate(tb2.Text)
Else
lrRng.Offset(, i) = ""
End If
Case Else
lrRng.Offset(, i) = Trim(Controls("tb" & i + 1).Value)
End Select
Next i
I have this code that I am using to update my database.
Column A contain IDs and one id could exist multiple times.
The ID field is the tb1. I have been finding the accumilated balance then add it to the new record I add thhrough the update process.
My goal here is to place only on data for balance for each ID. See the image for clarity.
I need a way to achieve this.
I sort data by date first then Account number all in ascending order.
Thanks for your help.