New Member
February 2, 2021
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
1 Guest(s)