L
LC
Hi,
First of all I am very sorry for forgetting to attach my
code to my previous email so here it is:
For Each categ1 In Category.Cells
If (categ1.Value <> "") Then
If (categ1.Value = categ1.Offset(1, 0).Value) Then
'working on later
ElseIf (categ1.Offset(1, 0).Value <> "") And
(categ1.Value <> categ1.Offset(1, 0).Value) Then
categ1.Activate
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
ElseIf (categ1.Offset(1, 0).Value = "") And (start > 1)
Then
'I used the start counter to skip the first empty
cell
'the last row total
categ1.Activate
ActiveCell.Offset(1, 0).Rows
("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
CatTot = CatTot + 1
'CatTot is my counter for CatTot to use for my
formula
categ1.Offset(1, 0).Value = "Total "
categ1.Offset(1, 1).Value = categ1.Value
'diff2 is how much to move right of the cell
categ1.Offset(1, diff2).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" + Str(-CatTot)
+ "]C:R[-1]C)"
End If
start = start + 1
CatTot = CatTot + 1
ElseIf (categ1.Value = "") And (start > 1) Then
categ1.Value = "Total "
categ1.Offset(0, 1).Value = categ1.Offset(-
1, 0).Value
categ1.Offset(0, diff2).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" + Str(-
CatTot) + "]C:R[-1]C)"
'Exit For
End If
Next categ1
Thank you in advance,
LC
First of all I am very sorry for forgetting to attach my
code to my previous email so here it is:
For Each categ1 In Category.Cells
If (categ1.Value <> "") Then
If (categ1.Value = categ1.Offset(1, 0).Value) Then
'working on later
ElseIf (categ1.Offset(1, 0).Value <> "") And
(categ1.Value <> categ1.Offset(1, 0).Value) Then
categ1.Activate
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
ElseIf (categ1.Offset(1, 0).Value = "") And (start > 1)
Then
'I used the start counter to skip the first empty
cell
'the last row total
categ1.Activate
ActiveCell.Offset(1, 0).Rows
("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown
CatTot = CatTot + 1
'CatTot is my counter for CatTot to use for my
formula
categ1.Offset(1, 0).Value = "Total "
categ1.Offset(1, 1).Value = categ1.Value
'diff2 is how much to move right of the cell
categ1.Offset(1, diff2).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" + Str(-CatTot)
+ "]C:R[-1]C)"
End If
start = start + 1
CatTot = CatTot + 1
ElseIf (categ1.Value = "") And (start > 1) Then
categ1.Value = "Total "
categ1.Offset(0, 1).Value = categ1.Offset(-
1, 0).Value
categ1.Offset(0, diff2).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" + Str(-
CatTot) + "]C:R[-1]C)"
'Exit For
End If
Next categ1
Thank you in advance,
LC