You are on page 1of 2

Public NewPart As String, NewSpot As String, OldPart As String, NewTime As Varia

nt, Frmla As String, Frmla2 As String, Switch As String


Sub FindSpot()
For Column = 2 To 28 Step 2
For Row = 2 To 38
Cells(Row, Column).Select
OldPart = ActiveCell.Value
If NewPart = OldPart Then
MsgBox ("Part number already exists")
Switch = "On"
Exit Sub
End If
If NewPart < OldPart Then
NewSpot = ActiveCell.Address
Exit Sub
End If
Next Row
Next Column
MsgBox ("Unable to find the right place.")
Switch = "On"
End Sub
Sub InsertSpot()
'tc = ActiveCell.Column
Frmla = "=HYPERLINK(" & Chr(34) & "[Cycle Time Records.xlsm]'" & NewPart & "
'!A1" & Chr(34) & "," & Chr(34) & NewPart & Chr(34) & ")"
Frmla2 = "='" & NewPart & "'!H3"
Sheets("Table of Contents").Select
tc = ActiveCell.Column
Range(ActiveCell, ActiveCell.Offset(0, 1)).Select
Selection.Insert Shift:=xlDown
Range(NewSpot).Select
ActiveCell.Formula = Frmla
ActiveCell.Offset(0, 1).Formula = Frmla2
For i = tc To 26 Step 2
Cells(39, i).Select
Range(ActiveCell, ActiveCell.Offset(0, 1)).Select
Selection.Cut
Cells(2, i + 2).Select
Range(ActiveCell, ActiveCell.Offset(0, 1)).Select
Selection.Insert Shift:=xlDown
Next i
Range("AB39:AC39").Select
Selection.Borders.LineStyle = xlNone
Range("AB38:AC38").Select
Selection.Borders.LineStyle = xlContinuous
End Sub
Sub InsertPage()
For Each Sheet In ActiveWorkbook.Sheets

If UCase(Sheet.Name) = UCase(NewPart) Then


MsgBox "Sheet already exists!", vbCritical
Switch = "On"
Exit Sub
End If
Next Sheet
Sheets("Master").Select
Sheets("Master").Copy before:=Sheets(OldPart)
Sheets("Master (2)").Name = NewPart
Sheets(NewPart).Range("A2").Value = NewPart
Sheets(NewPart).Range("F3").Formula = "=" & 60 / NewTime & "/1440"
End Sub
Private Sub Close_Button_Click()
Unload Me
End Sub
Private Sub Insert_Button_Click()
Switch = "Off"
NewPart = UCase(Me.NewPartV.Value)
NewTime = Me.NewTimeV.Value
Call FindSpot
If Switch = "On" Then Exit Sub
Call InsertPage
If Switch = "On" Then Exit Sub
Call InsertSpot
Range("A1").Select
Range("A36").Formula = "=COUNTA(C2:C38,E2:E38,G2:G38,I2:I38,K2:K38,M2:M38,O2
:O38,Q2:Q38,S2:S38,U2:U38,W2:W38,Y2:Y38,AA2:AA38,AC2:AC38)"
End Sub