Tron57
Board Regular
- Joined
- Sep 26, 2002
- Messages
- 66
Because of stack space issues i need to clean my code up, which is posted on the bottom.
Im wondering how to use Looping effectivly the project im working on will need to loop an unkown amount of times, depending on what the raw data is. can you post a few good examples of looping code and explan what is does. (step by setp.
or if you could adjust my below code i think i would learn alot from it, being i could compare what i wrote to what is more efficient.
Sub LoopBlank()
Call FillBlank
End Sub
Sub loopblank2()
If ActiveCell.Offset(1, -1).Value <> "" Then
ActiveCell.Offset(1, 0).Select
Call FillBlank
End If
Application.Run "MacroSheetNEW.xls!Name_or_Contract"
'End If
End Sub
Sub FillBlank()
If ActiveCell <> "" Then
ActiveCell.Offset(1, 0).Select
'Call LoopBlank
End If
If ActiveCell.Offset(0, -1).Value = "Sum:" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlank
End If
If ActiveCell.Offset(0, -1).Value = "Average:" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlank
End If
If ActiveCell.Offset(0, -1).Value = "" Then
ActiveCell.Offset(1, 0).Select
Call loopblank2
End If
If ActiveCell.Offset(0, -1).Value <> "" Then
ActiveCell.Formula = "No Contract"
ActiveCell.Offset(1, 0).Select
Call LoopBlank
End If
End Sub
Sub LoopBlankOLD()
Call FillBlankOLD
End Sub
__________________________________________
different macro but same concept
____________________________________
Sub FillBlankOLD()
ActiveCell.Select
If ActiveCell <> "" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
Else
ActiveCell.Select
If ActiveCell.Offset(0, -1).Value = "Sum:" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
ElseIf ActiveCell.Offset(0, -1).Value = "Average:" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
ElseIf ActiveCell.Offset(0, -1).Value = "" Then
If ActiveCell.Offset(1, -1).Value = "" Then
Application.Run "MacroSheetNEW.xls!OldSkoolTwo" ' calls Old_Format
Else
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
End If
ElseIf ActiveCell.Offset(0, -1).Value <> "" Then
ActiveCell.Formula = "No Contract"
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
End If
End If
End Sub
Im wondering how to use Looping effectivly the project im working on will need to loop an unkown amount of times, depending on what the raw data is. can you post a few good examples of looping code and explan what is does. (step by setp.
or if you could adjust my below code i think i would learn alot from it, being i could compare what i wrote to what is more efficient.
Sub LoopBlank()
Call FillBlank
End Sub
Sub loopblank2()
If ActiveCell.Offset(1, -1).Value <> "" Then
ActiveCell.Offset(1, 0).Select
Call FillBlank
End If
Application.Run "MacroSheetNEW.xls!Name_or_Contract"
'End If
End Sub
Sub FillBlank()
If ActiveCell <> "" Then
ActiveCell.Offset(1, 0).Select
'Call LoopBlank
End If
If ActiveCell.Offset(0, -1).Value = "Sum:" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlank
End If
If ActiveCell.Offset(0, -1).Value = "Average:" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlank
End If
If ActiveCell.Offset(0, -1).Value = "" Then
ActiveCell.Offset(1, 0).Select
Call loopblank2
End If
If ActiveCell.Offset(0, -1).Value <> "" Then
ActiveCell.Formula = "No Contract"
ActiveCell.Offset(1, 0).Select
Call LoopBlank
End If
End Sub
Sub LoopBlankOLD()
Call FillBlankOLD
End Sub
__________________________________________
different macro but same concept
____________________________________
Sub FillBlankOLD()
ActiveCell.Select
If ActiveCell <> "" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
Else
ActiveCell.Select
If ActiveCell.Offset(0, -1).Value = "Sum:" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
ElseIf ActiveCell.Offset(0, -1).Value = "Average:" Then
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
ElseIf ActiveCell.Offset(0, -1).Value = "" Then
If ActiveCell.Offset(1, -1).Value = "" Then
Application.Run "MacroSheetNEW.xls!OldSkoolTwo" ' calls Old_Format
Else
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
End If
ElseIf ActiveCell.Offset(0, -1).Value <> "" Then
ActiveCell.Formula = "No Contract"
ActiveCell.Offset(1, 0).Select
Call LoopBlankOLD
End If
End If
End Sub