I am trying to loop the long code below until ...
If I cannot loop the code using the condition then looping the code for a specified number of times will suffice ... I am a novice with VBA so forgive me if I am going at this wrong to begin with but my desired result can be achieved by simply looping the code below.
Thank you so much for any help
Code:
ActiveCell.Offset(1, -11) = ""
Thank you so much for any help
Code:
Let X = 0
Do Until ActiveCell.Offset(0, -11) <> ActiveCell.Offset(1, -11)
If ActiveCell.Offset(0, -11) = ActiveCell.Offset(1, -11) Then
NextFree = Range("AD2:AD" & Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
Range("AD" & NextFree).Select
ActiveCell.Offset(0, -1).Select
Selection.FormulaR1C1 = "=IF(RC[-2]>0,RC[-2],0)"
ActiveCell.Offset(0, 1).Select
Selection.FormulaR1C1 = _
"=IF(AND(RC[-3]>0,RC[2]>-1,RC[3]>-1,RC[4]>-1,RC[5]>-1),RC[-3],0)"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, -1).Select
Selection.ClearContents
Else
ActiveCell.Offset(0, -2).Select
Selection.FormulaR1C1 = _
"=IF(SUMIF(R2C18:R1000C18,RC[-10],R2C27:R1000C27)=SUMIF(R2C18:R1000C18,RC[-10],R2C30:R1000C30),RC[2],0)"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
Selection.ClearContents
End If
X = X + 1
Loop
ActiveCell.Offset(0, -1).Select
Do Until ActiveCell.Offset(0, -10) <> ActiveCell.Offset(-1, -10)
ActiveCell.Offset(0, -10) = ActiveCell.Offset(-1, -10)
Selection.FormulaR1C1 = _
"=IF(SUMIF(R2C18:R1000C18,RC[-10],R2C27:R1000C27)=SUMIF(R2C18:R1000C18,RC[-10],R2C30:R1000C30),RC[2],0)"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(-1, 0).Select
X = X + 1
Loop
Selection.FormulaR1C1 = _
"=IF(SUMIF(R2C18:R1000C18,RC[-10],R2C27:R1000C27)=SUMIF(R2C18:R1000C18,RC[-10],R2C30:R1000C30),RC[2],0)"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select