Forum

VBA code for daily ...
 
Notifications
Clear all

VBA code for daily expenses.

3 Posts
2 Users
0 Reactions
91 Views
(@uhsnamih)
Posts: 2
New Member
Topic starter
 

Have some heads of daily expenses in Col. B . if I spend some money on any head I write down it Col. C against that head. In col. D I select mode of payment for example "Cash", "DebitCard" and "CreditCard". In Cells F3, G3 and H3 I have Total money in that account that is "CASH", "DebitCard" and "CreditCard" respectively. The following is the VBA code which I am using. But the problem is that if do not have any amount in C3 no value is deducted from any head. What ever value is in C3 that is deducted from every head. I want it to deduct the corresponding amount from the related head . Please help

Sub Cash()
Dim i As Integer
i = 1
Do Until i > 11
If Cells(i, "D").Value = "Cash" Then
Range("F3").Value = Range("F3").Value - Range("C3").Value
End If
i = i + 1
Loop

End Sub
Sub DebitCard()
Dim i As Integer
i = 1
Do Until i > 11
If Cells(i, "D").Value = "DebitCard" Then
Range("G3").Value = Range("G3").Value - Range("C3").Value
End If
i = i + 1
Loop

End Sub
Sub CreditCard()
Dim i As Integer
i = 1
Do Until i > 11
If Cells(i, "D").Value = "CreditCard" Then
Range("H3").Value = Range("H3").Value - Range("C3").Value
End If
i = i + 1
Loop

End Sub

Sub Clear()
Worksheets("Sheet1").Range("C3:C11").ClearContents
End Sub

Sub AllInOne()
Call Cash
Call DebitCard
Call CreditCard
Call Clear
End Sub

 
Posted : 02/02/2021 1:27 pm
(@purfleet)
Posts: 412
Reputable Member
 

Please add a workbook with the code and examples it makes error checking so much easier

 
Posted : 03/02/2021 3:40 pm
(@uhsnamih)
Posts: 2
New Member
Topic starter
 

Work Book is attached herewith for ready reference please.

 
Posted : 04/02/2021 1:07 pm
Share: