0

hi all

i am newbie in Excel VBA

i created list in Excel and i wrote into (**a1** cell-income, **b1** cell-expence, **c1** cell-kredit and **d1** cell-debet)

i enter a2 cell income (for ex:1000) and b2 cell expence (for ex: 100)

and I give condition in VBA that if income greater than expence then VBA writes a2.value-b2.value into d2 cell

else if expence greater than income then it writes b2.value-a2.value into c2 cell

but i only define this one row (for ex: c2, a2. b2. d2)

i would like to assign it the rows as long as i want

that is i would like to create loop

(for ex: a(i), b(i) and so on

here is code

pls help me i very need this code

thanks beforehands

```
Sub initialize()
Dim i As Integer
Dim lastrow As Long
If (Range("b2").Value > Range("a2").Value) Then
Range("c2").Value = Range("b2").Value - Range("a2").Value
Range("d2").Value = ""
Else
Range("d2").Value = Range("a2").Value - Range("b2").Value
Range("c2").Value = ""
End If
End Sub
```

*Edited 7 Years Ago by azegurb*: n/a