Here is the code for adding rows: (I'm still struggling with this one a little but it seems to work so far)
' Add_Rows_Devaiation Macro
' Macro recorded 9/9/2002 by Gary Kapsner
' Macro edited 10/24/2007 by Mike Hemm
' Macro edited 01/06/2009 by Mike Shadick
Application.ScreenUpdating = False
Dim Check, Counter, Features As Range, Message, Title, Default, FeaturesValue
Dim MLRValue
TOTAL = TextBox1
MMC = (TextBox2 * 5)
RFS = (TextBox3 * 3)
PROFILE = (TextBox4 * 2)
ADDITIONAL = TextBox5
FeaturesValue = (TOTAL + MMC + RFS + PROFILE + ADDITIONAL)
FeaturesValue = FeaturesValue - 2
If FeaturesValue < 1 Then
GoTo line3
Else
If FeaturesValue = 1 Then
GoTo line1
Else
GoTo line2
line1:
ActiveSheet.Rows(13).Select
Selection.Delete
Range("B12").Select
Unload Me
line2:
FeaturesValue = FeaturesValue - 2
Check = True: Counter = FeaturesValue ' Add number of features
ActiveSheet.Rows(13).Select
Selection.Copy
Do ' Outer loop.
Do While Counter > 0 ' Inner loop.
Counter = Counter - 1 ' Increment Counter.
ActiveCell.Offset(1, 0).Activate
ActiveSheet.Paste
If Counter = 0 Then ' If condition is True.
Check = False ' Set value of flag to False.
Exit Do ' Exit inner loop.
End If
Loop
Loop Until Check = False ' Exit outer loop immediately.
Application.CutCopyMode = False
Range("B12").Select
Unload Me
line3:
MsgBox "You can not have 0 features in this report. Please try again.", vbOKOnly
Unload Me
Line4:
Unload Me
End Sub
Here is the code for adding parts:
' AddParts Macro
' Macro recorded 5/7/2008 by AIS
Application.ScreenUpdating = False
Dim Check, Counter, Features As Range, Message, Title, Default, PartsValue
' Display message, title, and default value.
PartsValue = InputBox("Enter number of Parts", "Add Parts Columns", 0)
PartsValue = PartsValue - 1
If PartsValue = 0 Then GoTo line2 Else GoTo line1
line1:
Check = True: Counter = PartsValue ' Add number of parts
Range("J10").Select
Range("J10:K550").Select
Selection.Copy
Do ' Outer loop.
Do While Counter > 0 ' Inner loop.
Counter = Counter - 1 ' Increment Counter.
ActiveCell.Offset(0, 2).Activate
ActiveSheet.Paste
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = ActiveCell.Offset(0, -2) + 1
ActiveCell.Offset(0, -1).Activate
If Counter = 0 Then ' If condition is True.
Check = False ' Set value of flag to False.
Exit Do ' Exit inner loop.
End If
Loop
Loop Until Check = False ' Exit outer loop immediately.
Application.CutCopyMode = False
Range("B12").Select
line2:
End Sub