Sub okEnter()
'check that all entry's are correct
If IsNumeric(Me.Qty.Value) Then
Else
MsgBox "Enter Numbers Only"
Me.Qty.Value = ""
Me.Qty.SetFocus
Exit Sub
End If
If Me.Profile.Value = "" Then
MsgBox "Please fill in Profile detail"
Me.Profile.SetFocus
Exit Sub
End If
If Me.Size.Value = "" Then
MsgBox "Please fill in Size detail"
Me.Size.SetFocus
Exit Sub
End If
If Me.sWidth.Value = "" Then
MsgBox "Please fill in Width detail"
Me.sWidth.SetFocus
Exit Sub
End If
If Me.Timber.Value = "" Then
MsgBox "Please fill in Timber detail"
Me.Timber.SetFocus
Exit Sub
End If
Set ws = Worksheets("Table")
Set sr = Worksheets("Spice Racks")
Dim X As Long, Y As Long, tlr As Long, tlc As Long, side As Long, setUpPage As Long
Dim tbQty As Byte, tb As Byte, bars As Byte, shelveQty As Byte, shelve As Byte, shelveQty2 As Byte, shelve2 As Byte, shelveQty3 As Byte, shelve3 As Byte
Dim picture As String
tlr = ws.Cells(Rows.Count, 26).End(xlUp).Row
tlc = ws.Cells(1, Columns.Count).End(xlToLeft).Column
'Fill size list
For X = 1 To tlr
If ws.Cells(X, 26) = "Compontents" Then
headerRow = X
' tlc = ws.Cells(X, Columns.Count).End(xlToLeft).Column
For Y = X To tlr
If ws.Cells(Y, 26) = Me.Profile.Value & " " & Me.Size Then
side = ws.Cells(Y, 29)
tbQty = ws.Cells(Y, 30)
tb = ws.Cells(Y, 31)
barsQty = ws.Cells(Y, 32)
bars = ws.Cells(Y, 33)
shelveQty = ws.Cells(Y, 34)
shelve = ws.Cells(Y, 35)
shelveQty2 = ws.Cells(Y, 36)
shelve2 = ws.Cells(Y, 37)
shelveQty3 = ws.Cells(Y, 38)
shelve3 = ws.Cells(Y, 39)
GoTo exitnow
End If
Next Y
End If
Next X
exitnow:
'loop through range to create pages for printing
For setUpPage = 1 To 10000 Step 9
If Cells(1, setUpPage) = "Customer UI" Then
Else
If setUpPage = 1 Then
Else
.Range(.Cells(1, setUpPage - 9), .Cells(14, setUpPage - 1)).AutoFill Destination:=.Range(.Cells(1, setUpPage), .Cells(14, setUpPage + 9)).Address, Type:=xlFillDefault
End If
Cells(1, setUpPage) = "Customer UI"
Cells(2, setUpPage) = "Company"
Cells(3, setUpPage) = "Reference"
Cells(1, setUpPage + 2) = ws.Cells(1, 3)
Cells(2, setUpPage + 2) = ws.Cells(2, 3)
Cells(3, setUpPage + 2) = ws.Cells(3, 3)
Cells(4, setUpPage) = "Profile"
Cells(5, setUpPage) = "Timber"
Cells(4, setUpPage + 2) = Me.Profile.Value
Cells(5, setUpPage + 2) = Me.Timber.Value
Cells(7, setUpPage + 3) = "QTY"
Cells(7, setUpPage + 4) = "Height"
Cells(7, setUpPage + 5) = "Width"
Cells(8, setUpPage + 3) = Me.Qty.Value
Cells(8, setUpPage + 4) = Me.Size.Value
Cells(8, setUpPage + 5) = Me.sWidth.Value
Cells(10, setUpPage + 2) = "Cutting List"
Cells(11, setUpPage + 2) = "Sides"
Cells(12, setUpPage + 2) = "T & B Rails"
Cells(13, setUpPage + 2) = "Cross Bars"
Cells(14, setUpPage + 2) = "Shelves"
Columns(setUpPage + 2).ColumnWidth = 9.86
'Fill page number
Cells(48, setUpPage + 7) = "Page"
On Error GoTo Page1
pageNum = Cells(48, setUpPage - 1)
pageNum = pageNum + 1
Page1:
If pageNum = 0 Then
pageNum = 1
End If
On Error GoTo 0
Cells(39, setUpPage + 8) = pageNum
'fill cutting list
'sides
Cells(11, setUpPage + 3) = (Me.Qty.Value * 2) & " @ "
Cells(11, setUpPage + 4) = Me.Size.Value & " x " & side + 1
'top and bottom
Cells(12, setUpPage + 3) = (tbQty * Me.Qty.Value) & " @ "
Cells(12, setUpPage + 4) = (Me.sWidth.Value - 30) & " x " & tb + 1
'bars
Cells(13, setUpPage + 3) = (barsQty * Me.Qty.Value) & " @ "
Cells(13, setUpPage + 4) = (Me.sWidth.Value - 30) & " x " & bars + 1
'shelves
Cells(14, setUpPage + 3) = (shelveQty * Me.Qty.Value) & " @ "
Cells(14, setUpPage + 4) = (Me.sWidth.Value - 30) & " x " & shelve + 1
'shelves2
If shelevQty2 = "" Then
Else
Cells(15, setUpPage + 3) = (shelveQty2 * Me.Qty.Value) & " @ "
Cells(15, setUpPage + 4) = (Me.sWidth.Value - 30) & " x " & shelve2 + 1
End If
'shelves3
If shelevQty3 = "" Then
Else
Cells(16, setUpPage + 3) = (shelveQty3 * Me.Qty.Value) & " @ "
Cells(16, setUpPage + 4) = (Me.sWidth.Value - 30) & " x " & shelve3 + 1
End If
'Place and name picture
picture = Me.Profile.Value & " " & Me.Size.Value
ws.Shapes(picture).Copy
ActiveSheet.Paste
ActiveSheet.Shapes(picture).Name = picture & " " & pageNum
picture = picture & " " & pageNum
ActiveSheet.Shapes(picture).Visible = msoTrue
ActiveSheet.Shapes(picture).Top = 260
ActiveSheet.Shapes(picture).Left = Cells(1, setUpPage).Left
ActiveSheet.Shapes(picture).Width = Cells(1, setUpPage + 9).Left - Cells(1, setUpPage).Left
'set print area
With Sheets("Spice Racks")
.pagesetup.PrintArea = .Range(.Cells(1, 1), .Cells(50, setUpPage + 8)).Address
End With
'Clear User form boxes
Me.Qty.Value = ""
Me.Profile.Value = ""
Me.Size.Value = ""
Me.sWidth.Value = ""
Me.Timber.Value = ""
Exit Sub
End If
Next setUpPage
End Sub