Strooprover
New Member
- Joined
- Jul 21, 2017
- Messages
- 25
Hi all,
[TABLE="width: 395"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Costs[/TD]
[TD]Costs 2[/TD]
[TD]Total Costs[/TD]
[/TR]
[TR]
[TD]€15,00[/TD]
[TD]€0,00[/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]
I want to adjust my macro so it adds up the two costs in the totcal costs area. This has to be done fot a lot of rows. In between the rows in this column there are empty spaces. I made this formula, but when I use the sum formula it says: €15,00€0,00 in the total costs area.
Can someone help me?
[TABLE="width: 395"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]Costs[/TD]
[TD]Costs 2[/TD]
[TD]Total Costs[/TD]
[/TR]
[TR]
[TD]€15,00[/TD]
[TD]€0,00[/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]
I want to adjust my macro so it adds up the two costs in the totcal costs area. This has to be done fot a lot of rows. In between the rows in this column there are empty spaces. I made this formula, but when I use the sum formula it says: €15,00€0,00 in the total costs area.
Can someone help me?
Code:
Sub Macro1()
Dim ws2 As worksheet
Set ws2 = Sheets("Sheet2")
Dim kosten As String
totkosten = ws2.Range("E2").Value
i = 1
For x = 1 To 1000
keer = Range("F" & i).Value
If ws2.Cells(x, 5) = totkosten Then
ws2.Cells(x, 5).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.Range("A1:A" & keer).Value = ActiveCell.Offset(0, -2).Value + ActiveCell.Offset(0, -1).Value
i = i + 1
End If
Next x
End Sub