# Running Balance Calculation

#### AsifShah

##### New Member
I was Created a userform for invoice control. in this userform i was created 3 Textbox.
Textbox1 For Old Running Balance
Textbox 2 For Current Bill
Textbox 3 For Result,
If Customer running Balance in Debit then Texbox1 Value + Textbox2 Value show result in Textbox3 and if Customer Running Balance is Credit then Textbox1 Value - Textbox2 Value and show the Result in Textbox3. Please Help

### Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Cross-posted

#### AsifShah

##### Active Member
What do you mean by "Running Balance in Debit" and "Running Balance in Credit"???
Does it means Running Balance is + and Running Balance is -, respectively???

#### AsifShah

##### New Member

What do you mean by "Running Balance in Debit" and "Running Balance in Credit"???
Does it means Running Balance is + and Running Balance is -, respectively???
Running Balance in Debit = " - "
Running Balance in Debit" = " + "

#### AsifShah

##### New Member
Running Balance in Debit = " - "
Running Balance in Credit = " + "
What do you mean by "Running Balance in Debit" and "Running Balance in Credit"???
Does it means Running Balance is + and Running Balance is -, respectively???

##### Active Member
Replace your code with the one below and see if it works

VBA Code:
``````Private Sub Code_AfterUpdate()
'Lookup values based on first control
With Me
.Dist = Application.WorksheetFunction.VLookup(CLng(Me.Code), Sheet3.Range("Subdealer"), 2, 0)
.TextBox2 = Application.WorksheetFunction.VLookup(CLng(Me.Code), Sheet3.Range("Subdealer"), 5, 0)

End With
If TextBox1.Text = "" And TextBox2.Text < 0 Then
TextBox3.Text = TextBox2.Text
Else
If TextBox1.Text = "" And TextBox2.Text > 0 Then
TextBox3.Text = TextBox2.Text
Else
If TextBox2.Text < 0 Then
Label186.Caption = "Old Credit"
TextBox3.Text = Val(TextBox1.Text) + Val(Abs(TextBox2.Text))
Else
Label186.Caption = "Old Debit"
TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
End If
End If
End If
End Sub``````

#### AsifShah

##### New Member
Replace your code with the one below and see if it works

VBA Code:
``````Private Sub Code_AfterUpdate()
'Lookup values based on first control
With Me
.Dist = Application.WorksheetFunction.VLookup(CLng(Me.Code), Sheet3.Range("Subdealer"), 2, 0)
.TextBox2 = Application.WorksheetFunction.VLookup(CLng(Me.Code), Sheet3.Range("Subdealer"), 5, 0)

End With
If TextBox1.Text = "" And TextBox2.Text < 0 Then
TextBox3.Text = TextBox2.Text
Else
If TextBox1.Text = "" And TextBox2.Text > 0 Then
TextBox3.Text = TextBox2.Text
Else
If TextBox2.Text < 0 Then
Label186.Caption = "Old Credit"
TextBox3.Text = Val(TextBox1.Text) + Val(Abs(TextBox2.Text))
Else
Label186.Caption = "Old Debit"
TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
End If
End If
End If
End Sub``````
Thanks Alot Brother Its Work for me

Replies
4
Views
309
Replies
5
Views
124
Replies
4
Views
170
Replies
18
Views
305
Replies
6
Views
149

1,136,632
Messages
5,676,888
Members
419,657
Latest member
ExcelAl1

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Which adblocker are you using?

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back