I have a sheet with below data.
Category | Amount | Daily Charges | Misc Charges | Vendor Charges
------------ |-----------| --------------|--------------|-------------------
Daily Charges |500,000.00 | | |
--------------|-----------|---------------|--------------|-------------------
Misc Charges | 500.00 | | |
--------------|-----------| --------------|--------------|-------------------
Vendor Charges| 50,000.00 | | |
I need to fill column 3 (Daily Charges) , column 4 (Misc Charges) and column 5(Vendor Charges) as below using macros.
Category | Amount | Daily Charges | Misc Charges | Vendor Charges
------------ |-----------| --------------|--------------|-------------------
Daily Charges |500,000.00 | 500,000.00 | 0 | 0
--------------|-----------|---------------|--------------|-------------------
Misc Charges | 500.00 | 0 | ₹ 500.00 | 0
--------------|-----------| --------------|--------------|-------------------
Vendor Charges| 50,000.00 | 0 | 0 | 50,000.00
Please help.
I tried the below macro function but i'm unable to exit correctly from the scope of a for each loop .
Sub LoopInsert()
Dim tgt, final, rng, val, cell, cell2, cell3 As Range
Worksheets("Sheet1").Activate
Set rng = ActiveSheet.Range("A2", ActiveSheet.Range("A2").End(xlDown))
Set val = ActiveSheet.Range("B2", ActiveSheet.Range("B2").End(xlDown))
Set tgt = ActiveSheet.Range("C2", ActiveSheet.Range("C2").End(xlDown))
For Each cell In rng
For Each cell2 In val
If cell.Value = "Daily Charges" Then
Exit For
For Each cell3 In tgt
cell3.Value = cell2.Value
Exit For
Next
Else
For Each cell3 In tgt
cell3.Value = 0
Exit For
Next
End If
Next
Next
End Sub
