Hello everyone,
I am looking for a way to run this macro on a determined starting point not only on "m3137" but for example if I am in "A3194". It may be worth to mention that I added blank rows to make navigation easier and to have a cell to do the sum.
This is the code I used:
Sub AddBlankRows()
'
Dim iRow As Integer, iCol As Integer
Dim oRng As Range
Set oRng = Range("g2")
iRow = oRng.Row
iCol = oRng.Column
Do
'
If Cells(iRow + 1, iCol) <> Cells(iRow, iCol) Then
Cells(iRow + 1, iCol).EntireRow.Insert shift:=xlDown
iRow = iRow + 2
Else
iRow = iRow + 1
End If
'
Loop While Not Cells(iRow, iCol).Text = ""
'
End Sub
Thanks in advance
Selection.End(xlToRight).Select
Selection.End(xlToRight).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range("M3137:W3193").Select
Range("M3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("N3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("O3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("P3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("Q3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("R3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("S3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("T3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("U3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("V3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("W3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Selection.End(xlToRight).Select
Selection.End(xlToRight).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range("Y3137:AE3193").Select
Range("Y3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("Z3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AA3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AB3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AC3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AD3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AE3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Selection.End(xlDown).Select
Range("A3193").Select
Selection.End(xlToRight).Select
Range(Selection, Selection.End(xlToRight)).Select
Range("M3193:X3193").Select
Range("X3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(RC[-11]:RC[-1])"
Rows("3193:3193").Select
Range("M3193").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Range("A3194").Select
I am looking for a way to run this macro on a determined starting point not only on "m3137" but for example if I am in "A3194". It may be worth to mention that I added blank rows to make navigation easier and to have a cell to do the sum.
This is the code I used:
Sub AddBlankRows()
'
Dim iRow As Integer, iCol As Integer
Dim oRng As Range
Set oRng = Range("g2")
iRow = oRng.Row
iCol = oRng.Column
Do
'
If Cells(iRow + 1, iCol) <> Cells(iRow, iCol) Then
Cells(iRow + 1, iCol).EntireRow.Insert shift:=xlDown
iRow = iRow + 2
Else
iRow = iRow + 1
End If
'
Loop While Not Cells(iRow, iCol).Text = ""
'
End Sub
Thanks in advance
Selection.End(xlToRight).Select
Selection.End(xlToRight).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range("M3137:W3193").Select
Range("M3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("N3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("O3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("P3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("Q3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("R3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("S3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("T3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("U3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("V3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Range("W3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("M3137:W3193").Select
Selection.End(xlToRight).Select
Selection.End(xlToRight).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Range("Y3137:AE3193").Select
Range("Y3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("Z3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AA3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AB3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AC3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AD3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Range("AE3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-56]C:R[-1]C)"
Range("Y3137:AE3193").Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Selection.End(xlDown).Select
Range("A3193").Select
Selection.End(xlToRight).Select
Range(Selection, Selection.End(xlToRight)).Select
Range("M3193:X3193").Select
Range("X3193").Activate
ActiveCell.FormulaR1C1 = "=SUM(RC[-11]:RC[-1])"
Rows("3193:3193").Select
Range("M3193").Activate
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.End(xlToLeft).Select
Selection.End(xlToLeft).Select
Range("A3194").Select