Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Each....Next

Status
Not open for further replies.

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top