Guest_imported
New member
- Jan 1, 1970
- 0
I want to apply procedure on several selections (with CTRL),
but VBA doesn't accept it and I don't find the mistake.
The procedure is the following: (NbreRows is variable)
For Each cell In Selection
Selection.Resize(Rowsize:=2).Rows(2).EntireRow. _
Resize(Rowsize:=NbreRows).Insert Shift:=xlDown
Selection.Resize(Rowsize:=2).Rows(2).EntireRow. _
Resize(Rowsize:=NbreRows).Group
Selection.Resize(Rowsize:=2).Rows(2).EntireRow.Resize(Rowsize:=nbreRows).Interior.ColorIndex = 40
ActiveCell.Offset(0, 8).Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(R[+" & NbreRows & "]C:R[+1]C,R[+" & NbreRows & "]C[-2]:R[+1]C[-2])"
Selection.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(R[+" & NbreRows & "]C:R[+1]C,R[+" & NbreRows & "]C[-3]:R[+1]C[-3])"
Selection.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(R[+" & NbreRows & "]C:R[+1]C,R[+" & NbreRows & "]C[-4]:R[+1]C[-4])"
Selection.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(R[+" & NbreRows & "]C:R[+1]C,R[+" & NbreRows & "]C[-5]:R[+1]C[-5])"
Selection.Locked = True
Next cell
but VBA doesn't accept it and I don't find the mistake.
The procedure is the following: (NbreRows is variable)
For Each cell In Selection
Selection.Resize(Rowsize:=2).Rows(2).EntireRow. _
Resize(Rowsize:=NbreRows).Insert Shift:=xlDown
Selection.Resize(Rowsize:=2).Rows(2).EntireRow. _
Resize(Rowsize:=NbreRows).Group
Selection.Resize(Rowsize:=2).Rows(2).EntireRow.Resize(Rowsize:=nbreRows).Interior.ColorIndex = 40
ActiveCell.Offset(0, 8).Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(R[+" & NbreRows & "]C:R[+1]C,R[+" & NbreRows & "]C[-2]:R[+1]C[-2])"
Selection.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(R[+" & NbreRows & "]C:R[+1]C,R[+" & NbreRows & "]C[-3]:R[+1]C[-3])"
Selection.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(R[+" & NbreRows & "]C:R[+1]C,R[+" & NbreRows & "]C[-4]:R[+1]C[-4])"
Selection.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "=SUMPRODUCT(R[+" & NbreRows & "]C:R[+1]C,R[+" & NbreRows & "]C[-5]:R[+1]C[-5])"
Selection.Locked = True
Next cell