Hi - I am trying to loop through my code below Range("MonthCount2") times - which we'll say is 10.
Within this loop, I have an IF statement, which contains a loop of "Multival" times - which for the first loop through is 2.
My code does what i want (i.e. pastes the selection MultiVal times) but only does this for two selections. Does not continue MonthCount2 times.
Do I have my IF statement or loop in the wrong place? Am I missing something? Any help appreciated:
For x = 1 To Range("MonthCount2")
Sheets("Balance Sheet Calculations").Select
Cells(intRowNum, intColNum).Select
Range(ActiveCell, ActiveCell.Offset(0, 8)).Select
'columns being copied
Selection.Copy
Sheets("Funding").Select
Range("StartIntercompanyPaste").Select
'start of the short term funding sheet
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Calculate
NeedVal = ActiveCell.Offset(0, 7).Value
MsgBox NeedVal
ActiveCell.Offset(1, 0).Select
If NeedVal * -1 > intIncrement Then
MultiVal = NeedVal / intIncrement * -1
ActiveCell.Offset(-1, 7) = intIncrement * -1
Range(ActiveCell.Offset(-1, 0), ActiveCell.Offset(-1, 8)).Select
Selection.Copy
For y = 1 To MultiVal
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, 0).Select
Next y
End If
Call New_Cash_Optimization
intRowNum = intRowNum + 1
Next x
Within this loop, I have an IF statement, which contains a loop of "Multival" times - which for the first loop through is 2.
My code does what i want (i.e. pastes the selection MultiVal times) but only does this for two selections. Does not continue MonthCount2 times.
Do I have my IF statement or loop in the wrong place? Am I missing something? Any help appreciated:
For x = 1 To Range("MonthCount2")
Sheets("Balance Sheet Calculations").Select
Cells(intRowNum, intColNum).Select
Range(ActiveCell, ActiveCell.Offset(0, 8)).Select
'columns being copied
Selection.Copy
Sheets("Funding").Select
Range("StartIntercompanyPaste").Select
'start of the short term funding sheet
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Calculate
NeedVal = ActiveCell.Offset(0, 7).Value
MsgBox NeedVal
ActiveCell.Offset(1, 0).Select
If NeedVal * -1 > intIncrement Then
MultiVal = NeedVal / intIncrement * -1
ActiveCell.Offset(-1, 7) = intIncrement * -1
Range(ActiveCell.Offset(-1, 0), ActiveCell.Offset(-1, 8)).Select
Selection.Copy
For y = 1 To MultiVal
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, 0).Select
Next y
End If
Call New_Cash_Optimization
intRowNum = intRowNum + 1
Next x