olatzcelaya
Programmer
hi all,
I am doing a program in VBA. When I run the program the error shown in the subject appears. I can not find where the error is. If anybody can help I will appreciate it a lot.;-)
The code, where the error appears, is the following one (the variables have been defined previously):
Dim myNumberStacks As Integer
Dim myPalletWidth1 As Double
Dim myPalletLength1 As Double
Dim myTolerance As Integer
Dim myQuantity As Integer
Dim mySheetWidth As Double
Dim mySheetLength As Double
Dim myFluteWeight As Double
Dim myFluteThickness As Double
Dim myOverhang As Integer
Dim myPaperWeight As Double
Dim myLorryHeight As Integer
Dim myPalletHeight As Integer
Dim myNumberSheetsPalletWeight As Integer
Dim myMaterialHeight As Double
Dim myNumberSheetsPalletHeight As Integer
Dim myNumberSheetsPallet_1 As Integer
Dim myNumberSheetsStack_1 As Integer
Dim myNumberSheetsStack_A As Integer
Dim myNumberSheetsPallet_A As Integer
Dim myNumberSheetsStack_B As Integer
Dim myNumberSheetsPallet_B As Integer
Dim myOverallNumberPallets As Integer
Dim myFullPallets As Integer
Dim mySheetsRedistribute As Integer
Dim myNumberStacks_1 As Integer
Dim myNumberSheetsStack_2 As Integer
Dim myNumberSheetsPallet_2 As Integer
Dim myNumberStacks_2 As Integer
Dim myNumberSheetsLeftPartPallet As Integer
Dim myMaximumAddingSheetsPartPallet As Integer
Dim myNumberSheetsPartPallets As Integer
Dim Pallet_Width2(24) As Integer
Dim Pallet_Length2(24) As Integer
Dim myNumberPallets As Integer
Dim myPalletWidth As Integer
Dim myPalletLength As Integer
Dim i As Integer
Private Sub CommandButton8_Click()
If CommandButton12.Enabled = False Then
'The customer does not require a specific number of sheets per stack
If ComboBox7.Text = "F" Then
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
Sheet1.Cells(25, 22) = NO
' If there are cardboard sheets of "F" or "N" flute, the sheets in the last part pallet are not redistribute onto the other pallets. Even if the number of sheets in the last part pallet are less than the half of the maximum quantity. The reason of this is because they are very delicated flutes
If mySheetWidth <= 1200 And mySheetLength <= 1200 Then
myNumberSheetsStack_1 = 900
myNumberSheetsPallet_1 = 900
' If we have "N" or "F" flutes the number of stacks per pallet is always 1
ElseIf mySheetWidth > 1200 And mySheetLength > 1200 Then
myNumberSheetsStack_1 = 700
myNumberSheetsPallet_1 = 700
End If
ElseIf ComboBox7.Text = "N" Then
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
Sheet1.Cells(25, 22) = NO
' If there are cardboard sheets of "F" or "N" flute, the sheets in the last part pallet are not redistribute onto the other pallets. Even if the number of sheets in the last part pallet are less than the half of the maximum quantity. The reason of this is because they are very delicated flutes
If mySheetWidth <= 1200 And mySheetLength <= 1200 Then
myNumberSheetsStack_1 = 1200
myNumberSheetsPallet_1 = 1200
ElseIf mySheetWidth > 1200 And mySheetLength > 1200 Then
myNumberSheetsStack_1 = 1000
myNumberSheetsPallet_1 = 1000
End If
' In these if's we have defined the number of sheets per stacks and per pallet for "N" and "F" flute
ElseIf ComboBox7.Text = "B" Or ComboBox7.Text = "E" Or ComboBox7.Text = "EB" Or ComboBox7.Text = "EE" Or ComboBox7.Text = "NE" Then
myMaterialHeight = (myLorryHeight - 170 - (2 * myPalletHeight)) / 2
myNumberSheetsPalletHeight = (myMaterialHeight \ myFluteThickness) * myNumberStacks
myNumberSheetsPalletWeight = 750000 \ myPaperWeight
If myNumberSheetsPalletWeight <= myNumberSheetsPalletHeight Then
myNumberSheetsStack_A = myNumberSheetsPalletWeight \ myNumberStacks
myNumberSheetsPallet_A = myNumberSheetsStack_A * myNumberStacks
ElseIf myNumberSheetsPalletWeight > myNumberSheetsPalletHeight Then
myNumberSheetsStack_A = myMaterialHeight \ myFluteThickness
myNumberSheetsPallet_A = (myMaterialHeight \ myFluteThickness) * myNumberStacks
End If
End If
' In these last if's we decide the number of sheets per stack
ElseIf CommandButton12.Enabled = True Then
myNumberSheetsStack_B = Sheet1.Cells(5, 10)
myNumberSheetsPallet_B = myNumberSheetsStack_B * myNumberStacks
myMaterialHeight = (myLorryHeight - 170 - 2 * myPalletHeight) / 2
myNumberSheetsPalletHeight = (myMaterialHeight \ myFluteThickness) * myNumberStacks
myNumberSheetsPalletWeight = 750000 \ myPaperWeight
If myNumberSheetsPalletWeight <= myNumberSheetsPalletHeight Then
Do While myNumberSheetsPallet_B > myNumberSheetsPalletWeight
MsgBox "Introduce a new quantity of number of sheets per stack"
myNumberSheetsPallet_1 = myNumberSheetsStack_B * myNumberStacks
myNumberSheetsStack_1 = myNumberSheetsStack_B
Loop
ElseIf myNumberSheetsPalletWeight > myNumberSheetsPalletHeight Then
Do While myNumberSheetsPallet_B > myNumberSheetsPalletHeight
MsgBox "Introduce a new quantity of number of sheets per stack"
myNumberSheetsPallet_1 = myNumberSheetsStack_B * myNumberStacks
myNumberSheetsStack_1 = myNumberSheetsStack_B
Loop
End If
' In these last if's it is checked that the customer does not exceed the maximum number of sheets per stack
End If
'In the following steps we will checked if there are any part pallets
If ComboBox7.Text = "B" Or ComboBox7.Text = "E" Or ComboBox7.Text = "EB" Or ComboBox7.Text = "EE" Or ComboBox7.Text = "NE" Then
If (myQuantity Mod myNumberSheetsPallet_A) = 0 Then
myOverallNumberPallets = myQuantity \ myNumberSheetsPallet_A
myFullPallets = myOverallNumberPallets
' Here we have just calculated the overall number of pallets that the customer's order will use
myNumberSheetsStack_1 = myNumberSheetsStack_A
myNumberSheetsPallet_1 = myNumberSheetsPallet_A
Sheet1.Cells(25, 18) = NO
' There are NO part pallets
Sheet1.Cells(25, 22) = NO
' The redistribution action will not be done because there are no part pallets
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = False
' There are no part pallets so the button of the number of sheets in the last part pallet will not be enabled
ElseIf (myQuantity Mod myNumberSheetsPallet_A) <> 0 Then
myOverallNumberPallets = (myQuantity \ myNumberSheetsPallet_A) + 1
' Here we have just calculated the overall number of pallets that the customer's order will use
If (myQuantity Mod myNumberSheetsPallet_A) < (myNumberSheetsPallet_A \ 2) Then
Sheet1.Cells(25, 18) = NO
' There are NO part pallets
Sheet1.Cells(25, 22) = YES
' The redistribution action will be done because there are no part pallets
CommandButton15.Enabled = True
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = True
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = False
' There are no part pallets so the button of the number of sheets in the last part pallet will not be enabled
mySheetsRedistribute = myQuantity Mod myNumberSheetsPallet_A
' If the number of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet, then we distribute those sheets in the last part pallet onto the other ones
myFullPallets = myOverallNumberPallets - 1
If mySheetsRedistribute / (myNumberStacks * (myOverallNumberPallets - 1)) < 1 Then
' The overall number of stacks is bigger than the number of sheets of the last part pallet that should be distributed
myNumberSheetsStack_1 = myNumberSheetsStack_A + 1
myNumberSheetsPallet_1 = myNumberStacks * (myNumberSheetsStack_A + 1)
myNumberStacks_1 = mySheetsRedistribute
myNumberSheetsStack_2 = myNumberSheetsStack_A
myNumberSheetsPallet_2 = myNumberSheetsPallet_A
myNumberStacks_2 = myNumberStacks * myOverallNumberPallets - myNumberStacks_1
ElseIf mySheetsRedistribute / (myNumberStacks * (myOverallNumberPallets - 1)) >= 1 Then
' The overall number of stacks is smaller than the number of sheets of the last part pallet that should be distributed
myNumberSheetsStack_2 = (mySheetsRedistribute \ (myNumberStacks * (myOverallNumberPallets - 1))) + myNumberSheetsStack_A
myNumberSheetsPallet_2 = myNumberSheetsStack_2 * myNumberStacks
myNumberStacks_1 = mySheetsRedistribute Mod (myNumberStacks * (myOverallNumberPallets - 1))
myNumberStacks_2 = ((myOverallNumberPallets - 1) * myNumberStacks) - myNumberStacks_1
myNumberSheetsStacks_1 = myNumberSheetsStack_2 + 1
myNumberSheetsPallet_1 = myNumberSheetsStack_1 * myNumberStacks
End If
ElseIf (myQuantity Mod myNumberSheetsPallet_A) >= (myNumberSheetsPallet_A \ 2) Then
Sheet1.Cells(25, 18) = YES
' There are part pallets
Sheet1.Cells(25, 22) = NO
' The redistribution action will not be done because there are no part pallets
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = True
' There are part pallets so the button of the number of sheets in the last part pallet will be enabled
myFullPallets = myOverallNumberPallets - 1
mySheetsRedistribute = myQuantity Mod myNumberSheetsPallet_A
myNumberSheetsStacks_1 = myNumberSheetsStack_A
myNumberSheetsPallet_1 = myNumberSheetsPallet_A
myNumberStacks_1 = (myOverallNumberPallets - 1) * myNumberStacks
myNumberSheetsLeftPartPallet = myQuantity Mod myNumberSheetsPallet_A
' Next, the tolerance of each customer will be aplied
If ComboBox6.Text = "+3%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 3) \ 100
ElseIf ComboBox6.Text = "5%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 5) \ 100
ElseIf ComboBox6.Text = "10%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 10) \ 100
End If
If myNumberSheetsLeftPartPallet <= myMaximumAddingSheetsPartPallet Then
myNumberSheetsPartPallet = mySheetsRedistribute + myNumberSheetsLeftPartPallet
' The sheets that are left to get a full pallet are less than the maximum number of sheets that can be applied with the tolerance
ElseIf myNumberSheetsLeftPartPallet > myMaximumAddingSheetsPartPallet Then
myNumberSheetsPartPallet = mySheetsRedistribute + myMaximumAddingSheetsPartPallet
' The sheets that are left to get a full pallet are more than the maximum number of sheets that can be applied with the tolerance
End If
End If
End If
ElseIf ComboBox7.Text = "F" Or ComboBox7.Text = "N" Then
If myQuantity Mod myNumberSheetsPallet_A = 0 Then
myFullPallets = myOverallNumberPallets
myOverallNumberPallets = myQuantity \ myNumberSheetsPallet_A
' Here we have just calculated the overall number of pallets that the customer's order will use
myNumberSheetsStack_1 = myNumberSheetsStack_A
myNumberSheetsPallet_1 = myNumberSheetsPallet_A
myNumberStacks_1 = myOverallNumberPallets * myNumberStacks
Sheet1.Cells(25, 18) = NO
' There are NO part pallets
Sheet1.Cells(25, 22) = NO
' The redistribution action will not be done because there are no part pallets
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = False
' There are no part pallets so the button of the number of sheets in the last part pallet will not be enabled
ElseIf (myQuantity Mod myNumberSheetsPallet_A) <> 0 Then
myOverallNumberPallets = (myQuantity \ myNumberSheetsPallet_A) + 1
' Here we have just calculated the overall number of pallets that the customer's order will use
myFullPallets = myOverallNumberPallets - 1
Sheet1.Cells(25, 18) = YES
' There are part pallets
Sheet1.Cells(25, 22) = NO
' The redistribution action will not be done because there are no part pallets
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = True
' There are part pallets so the button of the number of sheets in the last part pallet will be enabled
mySheetsRedistribute = myQuantity Mod myNumberSheetsPallet_A
myNumberSheetsStacks_1 = myNumberSheetsStack_A
myNumberSheetsPallet_1 = myNumberSheetsPallet_A
myNumberStacks_1 = (myOverallNumberPallets - 1) * myNumberStacks
myNumberSheetsLeftPartPallet = myQuantity Mod myNumberSheetsPallet_A
' Next, the tolerance of each customer will be aplied
If ComboBox6.Text = "+3%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 3) \ 100
ElseIf ComboBox6.Text = "5%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 5) \ 100
ElseIf ComboBox6.Text = "10%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 10) \ 100
End If
If myNumberSheetsLeftPartPallet <= myMaximumAddingSheetsPartPallet Then
myNumberSheetsPartPallet = mySheetsRedistribute + myNumberSheetsLeftPartPallet
' The sheets that are left to get a full pallet are less than the maximum number of sheets that can be applied with the tolerance
ElseIf myNumberSheetsLeftPartPallet > myMaximumAddingSheetsPartPallet Then
myNumberSheetsPartPallet = mySheetsRedistribute + myMaximumAddingSheetsPartPallet
' The sheets that are left to get a full pallet are more than the maximum number of sheets that can be applied with the tolerance
End If
End If
End If
Sheet1.Cells(27, 18) = myNumberSheetsStack_1
Sheet1.Cells(29, 18) = myNumberSheetsPallet_1
Sheet1.Cells(31, 18) = myNumberSheetsStack_2
Sheet1.Cells(33, 18) = myNumberSheetsPallet_2
Sheet1.Cells(29, 22) = myNumberStacks_1
Sheet1.Cells(33, 22) = myNumberStacks_2
Sheet1.Cells(27, 22) = myNumberSheetsPartPallet
Sheet1.Cells(23, 18) = myFullPallets
Pallet_Width2(0) = 800
Pallet_Length2(0) = 800
Pallet_Width2(1) = 900
Pallet_Length2(1) = 800
Pallet_Width2(2) = 1000
Pallet_Length2(2) = 800
Pallet_Width2(3) = 1100
Pallet_Length2(3) = 800
Pallet_Width2(4) = 1200
Pallet_Length2(4) = 800
Pallet_Width2(5) = 1100
Pallet_Length2(5) = 900
Pallet_Width2(6) = 1200
Pallet_Length2(6) = 900
Pallet_Width2(7) = 1500
Pallet_Length2(7) = 900
Pallet_Width2(8) = 1000
Pallet_Length2(8) = 1000
Pallet_Width2(9) = 1100
Pallet_Length2(9) = 1000
Pallet_Width2(10) = 1200
Pallet_Length2(10) = 1000
Pallet_Width2(11) = 1400
Pallet_Length2(11) = 1000
Pallet_Width2(12) = 1100
Pallet_Length2(12) = 1100
Pallet_Width2(13) = 1200
Pallet_Length2(13) = 1100
Pallet_Width2(14) = 1600
Pallet_Length2(14) = 1100
Pallet_Width2(15) = 1200
Pallet_Length2(15) = 1200
Pallet_Width2(16) = 1300
Pallet_Length2(16) = 1100
Pallet_Width2(17) = 1300
Pallet_Length2(17) = 800
Pallet_Width2(18) = 1500
Pallet_Length2(18) = 1200
Pallet_Width2(19) = 1400
Pallet_Length2(19) = 1200
Pallet_Width2(20) = 1300
Pallet_Length2(20) = 1000
Pallet_Width2(21) = 1500
Pallet_Length2(21) = 1000
Pallet_Width2(22) = 1600
Pallet_Length2(22) = 800
Pallet_Width2(23) = 1600
Pallet_Length2(23) = 1600
If ComboBox5.Text = "YES" Then
'The customer decides the type of pallet to use
If ComboBox13.Text = "Standard" Then
' The customer requires a standard pallet, so we will join two or one pallet for the following cardboard sheet dimensions
If 1300 <= mySheetWidth <= 1760 And 1600 <= mySheetLength <= 3700 Then
myNumberPallets = 2
ElseIf 1300 > mySheetWidth And 1600 > mySheetLength Then
myNumberPallets = 1
End If
ElseIf ComboBox13.Test = "Bespoke" Then
' The customer requires a bespoke pallet, so we will join two or one pallet for the following cardboard sheet dimensions
If mySheetWidth = 1760 And mySheetLength = 3700 Then
myNumberPallets = 2
ElseIf mySheetWidth < 1760 And mySheetLength < 3700 Then
myNumberPallets = 1
End If
End If
If ComboBox3.Text = "YES" Then
'The customers allows overhang, so we will check if the pallet that the customer has required is correct one to use
If (myNumberPallets * myPalletWidth1) <= mySheetWidth <= (2 * myOverhang + myNumberPallets * myPalletWidth1) And (myNumberPallets * myPalletLength1) <= mySheetLength <= (2 * myOverhang + myNumberPallets * myPalletLength1) Then
myPalletWidth = myPalletWidth1
myPalletLength = myPalletLength1
ElseIf (2 * myOverhang + myNumberPallets * myPalletWidth1) < mySheetWidth < (myNumberPallets * myPalletWidth1) And (2 * myOverhang + myNumberPallets * myPalletLength1) < mySheetLength < (myNumberPallets * myPalletLength1) Then
MsgBox "Introduce a new pallet size to use. The chosen pallet doesn't fit to the dimension of the material"
End If
ElseIf ComboBox3.Text = "NO" Then
'The customers doesn't allow overhang, so we will check if the pallet that the customer has required is correct one to use
If (myNumberPallets * myPalletWidth1) = mySheetWidth And (myNumberPallets * myPalletLength1) = mySheetLength Then
myPalletWidth = myPalletWidth1
myPalletLength = myPalletLength1
ElseIf (myNumberPallets * myPalletWidth1) <> mySheetWidth And (myNumberPallets * myPalletLength1) <> mySheetLength Then
MsgBox "Introduce a new pallet size to use. The chosen pallet doesn't fit to the dimension of the material"
End If
End If
ElseIf ComboBox5.Text = "NO" Then
'We decide the type of pallet to use. We will take standard pallet always because this type of pallet fits better into the lorry
If 1300 <= mySheetWidth <= 1760 And 1600 <= mySheetLength <= 3700 Then
myNumberPallets = 2
ElseIf 1300 > mySheetWidth And 1600 > mySheetLength Then
myNumberPallets = 1
End If
If ComboBox3.Text = "YES" Then
'The customers allows overhang, so we will check if the pallet that the customer has required is correct one to use
i = 0
Do While (2 * myOverhang + myNumberPallets * Pallet_Width2(i)) < mySheetWidth < (myNumberPallets * Pallet_Width2(i)) And (2 * myOverhang + myNumberPallets * Pallet_Length2(i)) < mySheetLength < (myNumberPallets * Pallet_Length2(i)) And i <= 23
myPalletWidth = Pallet_Width2(i)
myPalletLength = Pallet_Length2(i)
i = i + 1
Loop
If i = 24 Then
MsgBox "No standard pallets fit with the customer order"
End If
'We have checked all standard pallets
ElseIf ComboBox3.Text = "NO" Then
'The customers doesn't allow overhang, so we will check if the pallet that the customer has required is correct one to use
i = 0
Do While (myNumberPallets * Pallet_Width2(i)) <> mySheetWidth And (myNumberPallets * Pallet_Length2(i)) <> mySheetLength And i <= 23
myPalletWidth = Pallet_Width2(i)
myPalletLength = Pallet_Length2(i)
i = i + 1
Loop
If i = 24 Then
MsgBox "No standard pallets fit with the customer order"
End If
'We have checked all standard pallets
End If
End If
myNumberPallets = Sheet1.Cells(20, 22)
myPalletLength = Sheet1.Cells(21, 18)
myPalletWidth = Sheet1.Cells(19, 18)
End Sub
THANKS A LOT
OLATZ
I am doing a program in VBA. When I run the program the error shown in the subject appears. I can not find where the error is. If anybody can help I will appreciate it a lot.;-)
The code, where the error appears, is the following one (the variables have been defined previously):
Dim myNumberStacks As Integer
Dim myPalletWidth1 As Double
Dim myPalletLength1 As Double
Dim myTolerance As Integer
Dim myQuantity As Integer
Dim mySheetWidth As Double
Dim mySheetLength As Double
Dim myFluteWeight As Double
Dim myFluteThickness As Double
Dim myOverhang As Integer
Dim myPaperWeight As Double
Dim myLorryHeight As Integer
Dim myPalletHeight As Integer
Dim myNumberSheetsPalletWeight As Integer
Dim myMaterialHeight As Double
Dim myNumberSheetsPalletHeight As Integer
Dim myNumberSheetsPallet_1 As Integer
Dim myNumberSheetsStack_1 As Integer
Dim myNumberSheetsStack_A As Integer
Dim myNumberSheetsPallet_A As Integer
Dim myNumberSheetsStack_B As Integer
Dim myNumberSheetsPallet_B As Integer
Dim myOverallNumberPallets As Integer
Dim myFullPallets As Integer
Dim mySheetsRedistribute As Integer
Dim myNumberStacks_1 As Integer
Dim myNumberSheetsStack_2 As Integer
Dim myNumberSheetsPallet_2 As Integer
Dim myNumberStacks_2 As Integer
Dim myNumberSheetsLeftPartPallet As Integer
Dim myMaximumAddingSheetsPartPallet As Integer
Dim myNumberSheetsPartPallets As Integer
Dim Pallet_Width2(24) As Integer
Dim Pallet_Length2(24) As Integer
Dim myNumberPallets As Integer
Dim myPalletWidth As Integer
Dim myPalletLength As Integer
Dim i As Integer
Private Sub CommandButton8_Click()
If CommandButton12.Enabled = False Then
'The customer does not require a specific number of sheets per stack
If ComboBox7.Text = "F" Then
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
Sheet1.Cells(25, 22) = NO
' If there are cardboard sheets of "F" or "N" flute, the sheets in the last part pallet are not redistribute onto the other pallets. Even if the number of sheets in the last part pallet are less than the half of the maximum quantity. The reason of this is because they are very delicated flutes
If mySheetWidth <= 1200 And mySheetLength <= 1200 Then
myNumberSheetsStack_1 = 900
myNumberSheetsPallet_1 = 900
' If we have "N" or "F" flutes the number of stacks per pallet is always 1
ElseIf mySheetWidth > 1200 And mySheetLength > 1200 Then
myNumberSheetsStack_1 = 700
myNumberSheetsPallet_1 = 700
End If
ElseIf ComboBox7.Text = "N" Then
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
Sheet1.Cells(25, 22) = NO
' If there are cardboard sheets of "F" or "N" flute, the sheets in the last part pallet are not redistribute onto the other pallets. Even if the number of sheets in the last part pallet are less than the half of the maximum quantity. The reason of this is because they are very delicated flutes
If mySheetWidth <= 1200 And mySheetLength <= 1200 Then
myNumberSheetsStack_1 = 1200
myNumberSheetsPallet_1 = 1200
ElseIf mySheetWidth > 1200 And mySheetLength > 1200 Then
myNumberSheetsStack_1 = 1000
myNumberSheetsPallet_1 = 1000
End If
' In these if's we have defined the number of sheets per stacks and per pallet for "N" and "F" flute
ElseIf ComboBox7.Text = "B" Or ComboBox7.Text = "E" Or ComboBox7.Text = "EB" Or ComboBox7.Text = "EE" Or ComboBox7.Text = "NE" Then
myMaterialHeight = (myLorryHeight - 170 - (2 * myPalletHeight)) / 2
myNumberSheetsPalletHeight = (myMaterialHeight \ myFluteThickness) * myNumberStacks
myNumberSheetsPalletWeight = 750000 \ myPaperWeight
If myNumberSheetsPalletWeight <= myNumberSheetsPalletHeight Then
myNumberSheetsStack_A = myNumberSheetsPalletWeight \ myNumberStacks
myNumberSheetsPallet_A = myNumberSheetsStack_A * myNumberStacks
ElseIf myNumberSheetsPalletWeight > myNumberSheetsPalletHeight Then
myNumberSheetsStack_A = myMaterialHeight \ myFluteThickness
myNumberSheetsPallet_A = (myMaterialHeight \ myFluteThickness) * myNumberStacks
End If
End If
' In these last if's we decide the number of sheets per stack
ElseIf CommandButton12.Enabled = True Then
myNumberSheetsStack_B = Sheet1.Cells(5, 10)
myNumberSheetsPallet_B = myNumberSheetsStack_B * myNumberStacks
myMaterialHeight = (myLorryHeight - 170 - 2 * myPalletHeight) / 2
myNumberSheetsPalletHeight = (myMaterialHeight \ myFluteThickness) * myNumberStacks
myNumberSheetsPalletWeight = 750000 \ myPaperWeight
If myNumberSheetsPalletWeight <= myNumberSheetsPalletHeight Then
Do While myNumberSheetsPallet_B > myNumberSheetsPalletWeight
MsgBox "Introduce a new quantity of number of sheets per stack"
myNumberSheetsPallet_1 = myNumberSheetsStack_B * myNumberStacks
myNumberSheetsStack_1 = myNumberSheetsStack_B
Loop
ElseIf myNumberSheetsPalletWeight > myNumberSheetsPalletHeight Then
Do While myNumberSheetsPallet_B > myNumberSheetsPalletHeight
MsgBox "Introduce a new quantity of number of sheets per stack"
myNumberSheetsPallet_1 = myNumberSheetsStack_B * myNumberStacks
myNumberSheetsStack_1 = myNumberSheetsStack_B
Loop
End If
' In these last if's it is checked that the customer does not exceed the maximum number of sheets per stack
End If
'In the following steps we will checked if there are any part pallets
If ComboBox7.Text = "B" Or ComboBox7.Text = "E" Or ComboBox7.Text = "EB" Or ComboBox7.Text = "EE" Or ComboBox7.Text = "NE" Then
If (myQuantity Mod myNumberSheetsPallet_A) = 0 Then
myOverallNumberPallets = myQuantity \ myNumberSheetsPallet_A
myFullPallets = myOverallNumberPallets
' Here we have just calculated the overall number of pallets that the customer's order will use
myNumberSheetsStack_1 = myNumberSheetsStack_A
myNumberSheetsPallet_1 = myNumberSheetsPallet_A
Sheet1.Cells(25, 18) = NO
' There are NO part pallets
Sheet1.Cells(25, 22) = NO
' The redistribution action will not be done because there are no part pallets
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = False
' There are no part pallets so the button of the number of sheets in the last part pallet will not be enabled
ElseIf (myQuantity Mod myNumberSheetsPallet_A) <> 0 Then
myOverallNumberPallets = (myQuantity \ myNumberSheetsPallet_A) + 1
' Here we have just calculated the overall number of pallets that the customer's order will use
If (myQuantity Mod myNumberSheetsPallet_A) < (myNumberSheetsPallet_A \ 2) Then
Sheet1.Cells(25, 18) = NO
' There are NO part pallets
Sheet1.Cells(25, 22) = YES
' The redistribution action will be done because there are no part pallets
CommandButton15.Enabled = True
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = True
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = False
' There are no part pallets so the button of the number of sheets in the last part pallet will not be enabled
mySheetsRedistribute = myQuantity Mod myNumberSheetsPallet_A
' If the number of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet, then we distribute those sheets in the last part pallet onto the other ones
myFullPallets = myOverallNumberPallets - 1
If mySheetsRedistribute / (myNumberStacks * (myOverallNumberPallets - 1)) < 1 Then
' The overall number of stacks is bigger than the number of sheets of the last part pallet that should be distributed
myNumberSheetsStack_1 = myNumberSheetsStack_A + 1
myNumberSheetsPallet_1 = myNumberStacks * (myNumberSheetsStack_A + 1)
myNumberStacks_1 = mySheetsRedistribute
myNumberSheetsStack_2 = myNumberSheetsStack_A
myNumberSheetsPallet_2 = myNumberSheetsPallet_A
myNumberStacks_2 = myNumberStacks * myOverallNumberPallets - myNumberStacks_1
ElseIf mySheetsRedistribute / (myNumberStacks * (myOverallNumberPallets - 1)) >= 1 Then
' The overall number of stacks is smaller than the number of sheets of the last part pallet that should be distributed
myNumberSheetsStack_2 = (mySheetsRedistribute \ (myNumberStacks * (myOverallNumberPallets - 1))) + myNumberSheetsStack_A
myNumberSheetsPallet_2 = myNumberSheetsStack_2 * myNumberStacks
myNumberStacks_1 = mySheetsRedistribute Mod (myNumberStacks * (myOverallNumberPallets - 1))
myNumberStacks_2 = ((myOverallNumberPallets - 1) * myNumberStacks) - myNumberStacks_1
myNumberSheetsStacks_1 = myNumberSheetsStack_2 + 1
myNumberSheetsPallet_1 = myNumberSheetsStack_1 * myNumberStacks
End If
ElseIf (myQuantity Mod myNumberSheetsPallet_A) >= (myNumberSheetsPallet_A \ 2) Then
Sheet1.Cells(25, 18) = YES
' There are part pallets
Sheet1.Cells(25, 22) = NO
' The redistribution action will not be done because there are no part pallets
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = True
' There are part pallets so the button of the number of sheets in the last part pallet will be enabled
myFullPallets = myOverallNumberPallets - 1
mySheetsRedistribute = myQuantity Mod myNumberSheetsPallet_A
myNumberSheetsStacks_1 = myNumberSheetsStack_A
myNumberSheetsPallet_1 = myNumberSheetsPallet_A
myNumberStacks_1 = (myOverallNumberPallets - 1) * myNumberStacks
myNumberSheetsLeftPartPallet = myQuantity Mod myNumberSheetsPallet_A
' Next, the tolerance of each customer will be aplied
If ComboBox6.Text = "+3%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 3) \ 100
ElseIf ComboBox6.Text = "5%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 5) \ 100
ElseIf ComboBox6.Text = "10%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 10) \ 100
End If
If myNumberSheetsLeftPartPallet <= myMaximumAddingSheetsPartPallet Then
myNumberSheetsPartPallet = mySheetsRedistribute + myNumberSheetsLeftPartPallet
' The sheets that are left to get a full pallet are less than the maximum number of sheets that can be applied with the tolerance
ElseIf myNumberSheetsLeftPartPallet > myMaximumAddingSheetsPartPallet Then
myNumberSheetsPartPallet = mySheetsRedistribute + myMaximumAddingSheetsPartPallet
' The sheets that are left to get a full pallet are more than the maximum number of sheets that can be applied with the tolerance
End If
End If
End If
ElseIf ComboBox7.Text = "F" Or ComboBox7.Text = "N" Then
If myQuantity Mod myNumberSheetsPallet_A = 0 Then
myFullPallets = myOverallNumberPallets
myOverallNumberPallets = myQuantity \ myNumberSheetsPallet_A
' Here we have just calculated the overall number of pallets that the customer's order will use
myNumberSheetsStack_1 = myNumberSheetsStack_A
myNumberSheetsPallet_1 = myNumberSheetsPallet_A
myNumberStacks_1 = myOverallNumberPallets * myNumberStacks
Sheet1.Cells(25, 18) = NO
' There are NO part pallets
Sheet1.Cells(25, 22) = NO
' The redistribution action will not be done because there are no part pallets
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = False
' There are no part pallets so the button of the number of sheets in the last part pallet will not be enabled
ElseIf (myQuantity Mod myNumberSheetsPallet_A) <> 0 Then
myOverallNumberPallets = (myQuantity \ myNumberSheetsPallet_A) + 1
' Here we have just calculated the overall number of pallets that the customer's order will use
myFullPallets = myOverallNumberPallets - 1
Sheet1.Cells(25, 18) = YES
' There are part pallets
Sheet1.Cells(25, 22) = NO
' The redistribution action will not be done because there are no part pallets
CommandButton15.Enabled = False
' The number of sheets per stack2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton16.Enabled = False
' The number of sheets per pallet2 will be enabled when we redistribute the sheets of the last part pallet onto the other pallets. This button will be enabled when we have a "B", "E", "EB", "EE", or "NE" flutes. And when the overall quantity of sheets in the last part pallet is less than the half of the maximum quantity that can be loaded per pallet
CommandButton9.Enabled = True
' There are part pallets so the button of the number of sheets in the last part pallet will be enabled
mySheetsRedistribute = myQuantity Mod myNumberSheetsPallet_A
myNumberSheetsStacks_1 = myNumberSheetsStack_A
myNumberSheetsPallet_1 = myNumberSheetsPallet_A
myNumberStacks_1 = (myOverallNumberPallets - 1) * myNumberStacks
myNumberSheetsLeftPartPallet = myQuantity Mod myNumberSheetsPallet_A
' Next, the tolerance of each customer will be aplied
If ComboBox6.Text = "+3%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 3) \ 100
ElseIf ComboBox6.Text = "5%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 5) \ 100
ElseIf ComboBox6.Text = "10%" Then
myMaximumAddingSheetsPartPallet = (myQuantity * 10) \ 100
End If
If myNumberSheetsLeftPartPallet <= myMaximumAddingSheetsPartPallet Then
myNumberSheetsPartPallet = mySheetsRedistribute + myNumberSheetsLeftPartPallet
' The sheets that are left to get a full pallet are less than the maximum number of sheets that can be applied with the tolerance
ElseIf myNumberSheetsLeftPartPallet > myMaximumAddingSheetsPartPallet Then
myNumberSheetsPartPallet = mySheetsRedistribute + myMaximumAddingSheetsPartPallet
' The sheets that are left to get a full pallet are more than the maximum number of sheets that can be applied with the tolerance
End If
End If
End If
Sheet1.Cells(27, 18) = myNumberSheetsStack_1
Sheet1.Cells(29, 18) = myNumberSheetsPallet_1
Sheet1.Cells(31, 18) = myNumberSheetsStack_2
Sheet1.Cells(33, 18) = myNumberSheetsPallet_2
Sheet1.Cells(29, 22) = myNumberStacks_1
Sheet1.Cells(33, 22) = myNumberStacks_2
Sheet1.Cells(27, 22) = myNumberSheetsPartPallet
Sheet1.Cells(23, 18) = myFullPallets
Pallet_Width2(0) = 800
Pallet_Length2(0) = 800
Pallet_Width2(1) = 900
Pallet_Length2(1) = 800
Pallet_Width2(2) = 1000
Pallet_Length2(2) = 800
Pallet_Width2(3) = 1100
Pallet_Length2(3) = 800
Pallet_Width2(4) = 1200
Pallet_Length2(4) = 800
Pallet_Width2(5) = 1100
Pallet_Length2(5) = 900
Pallet_Width2(6) = 1200
Pallet_Length2(6) = 900
Pallet_Width2(7) = 1500
Pallet_Length2(7) = 900
Pallet_Width2(8) = 1000
Pallet_Length2(8) = 1000
Pallet_Width2(9) = 1100
Pallet_Length2(9) = 1000
Pallet_Width2(10) = 1200
Pallet_Length2(10) = 1000
Pallet_Width2(11) = 1400
Pallet_Length2(11) = 1000
Pallet_Width2(12) = 1100
Pallet_Length2(12) = 1100
Pallet_Width2(13) = 1200
Pallet_Length2(13) = 1100
Pallet_Width2(14) = 1600
Pallet_Length2(14) = 1100
Pallet_Width2(15) = 1200
Pallet_Length2(15) = 1200
Pallet_Width2(16) = 1300
Pallet_Length2(16) = 1100
Pallet_Width2(17) = 1300
Pallet_Length2(17) = 800
Pallet_Width2(18) = 1500
Pallet_Length2(18) = 1200
Pallet_Width2(19) = 1400
Pallet_Length2(19) = 1200
Pallet_Width2(20) = 1300
Pallet_Length2(20) = 1000
Pallet_Width2(21) = 1500
Pallet_Length2(21) = 1000
Pallet_Width2(22) = 1600
Pallet_Length2(22) = 800
Pallet_Width2(23) = 1600
Pallet_Length2(23) = 1600
If ComboBox5.Text = "YES" Then
'The customer decides the type of pallet to use
If ComboBox13.Text = "Standard" Then
' The customer requires a standard pallet, so we will join two or one pallet for the following cardboard sheet dimensions
If 1300 <= mySheetWidth <= 1760 And 1600 <= mySheetLength <= 3700 Then
myNumberPallets = 2
ElseIf 1300 > mySheetWidth And 1600 > mySheetLength Then
myNumberPallets = 1
End If
ElseIf ComboBox13.Test = "Bespoke" Then
' The customer requires a bespoke pallet, so we will join two or one pallet for the following cardboard sheet dimensions
If mySheetWidth = 1760 And mySheetLength = 3700 Then
myNumberPallets = 2
ElseIf mySheetWidth < 1760 And mySheetLength < 3700 Then
myNumberPallets = 1
End If
End If
If ComboBox3.Text = "YES" Then
'The customers allows overhang, so we will check if the pallet that the customer has required is correct one to use
If (myNumberPallets * myPalletWidth1) <= mySheetWidth <= (2 * myOverhang + myNumberPallets * myPalletWidth1) And (myNumberPallets * myPalletLength1) <= mySheetLength <= (2 * myOverhang + myNumberPallets * myPalletLength1) Then
myPalletWidth = myPalletWidth1
myPalletLength = myPalletLength1
ElseIf (2 * myOverhang + myNumberPallets * myPalletWidth1) < mySheetWidth < (myNumberPallets * myPalletWidth1) And (2 * myOverhang + myNumberPallets * myPalletLength1) < mySheetLength < (myNumberPallets * myPalletLength1) Then
MsgBox "Introduce a new pallet size to use. The chosen pallet doesn't fit to the dimension of the material"
End If
ElseIf ComboBox3.Text = "NO" Then
'The customers doesn't allow overhang, so we will check if the pallet that the customer has required is correct one to use
If (myNumberPallets * myPalletWidth1) = mySheetWidth And (myNumberPallets * myPalletLength1) = mySheetLength Then
myPalletWidth = myPalletWidth1
myPalletLength = myPalletLength1
ElseIf (myNumberPallets * myPalletWidth1) <> mySheetWidth And (myNumberPallets * myPalletLength1) <> mySheetLength Then
MsgBox "Introduce a new pallet size to use. The chosen pallet doesn't fit to the dimension of the material"
End If
End If
ElseIf ComboBox5.Text = "NO" Then
'We decide the type of pallet to use. We will take standard pallet always because this type of pallet fits better into the lorry
If 1300 <= mySheetWidth <= 1760 And 1600 <= mySheetLength <= 3700 Then
myNumberPallets = 2
ElseIf 1300 > mySheetWidth And 1600 > mySheetLength Then
myNumberPallets = 1
End If
If ComboBox3.Text = "YES" Then
'The customers allows overhang, so we will check if the pallet that the customer has required is correct one to use
i = 0
Do While (2 * myOverhang + myNumberPallets * Pallet_Width2(i)) < mySheetWidth < (myNumberPallets * Pallet_Width2(i)) And (2 * myOverhang + myNumberPallets * Pallet_Length2(i)) < mySheetLength < (myNumberPallets * Pallet_Length2(i)) And i <= 23
myPalletWidth = Pallet_Width2(i)
myPalletLength = Pallet_Length2(i)
i = i + 1
Loop
If i = 24 Then
MsgBox "No standard pallets fit with the customer order"
End If
'We have checked all standard pallets
ElseIf ComboBox3.Text = "NO" Then
'The customers doesn't allow overhang, so we will check if the pallet that the customer has required is correct one to use
i = 0
Do While (myNumberPallets * Pallet_Width2(i)) <> mySheetWidth And (myNumberPallets * Pallet_Length2(i)) <> mySheetLength And i <= 23
myPalletWidth = Pallet_Width2(i)
myPalletLength = Pallet_Length2(i)
i = i + 1
Loop
If i = 24 Then
MsgBox "No standard pallets fit with the customer order"
End If
'We have checked all standard pallets
End If
End If
myNumberPallets = Sheet1.Cells(20, 22)
myPalletLength = Sheet1.Cells(21, 18)
myPalletWidth = Sheet1.Cells(19, 18)
End Sub
THANKS A LOT
OLATZ