Cacoethes
New Member
- Joined
- Jun 18, 2020
- Messages
- 6
- Office Version
- 2016
- Platform
- Windows
Using Excel 2016 Windows, I am basically new to MrExcel and this is my first Thread. I am basically self taught and do this for enjoyment and not for any work projects. I am trying to make a pretty large UserForm program for
my first time at UserForm. So, I am finding some difference between Excel and UserForm programming but find it interesting.
My problem is that I am trying to divide two variables, each are, variable = ##.## / #.## (SliceVm = PanVt / SliceVt) and get an error 6, overflow ( the actual line is "SliceVm = Application.Round((PanVt / SliceVt), 2)".
I have tried several options but I just don't get the results without the overflow?
I have set the variables up in "Option Explicit" with Public ****** As Double and have tried Long but still get the error. I can Divide either number by an actual number and it works such as "SliceVm = PanVt / 6.73"
but, when I put them together the error occurs?
I have copied the Option Explicit, and sections of the routines that pertain to the values of the variables. I have also included the full routine of the section I am having issues with. By the way this is the first time I have ever
used Public variables, but I don't think that is an issue here. I have Also made the line with the error in BOLD for you.
Any help would be appreciated. I hope I have done this correctly in your system...
my first time at UserForm. So, I am finding some difference between Excel and UserForm programming but find it interesting.
My problem is that I am trying to divide two variables, each are, variable = ##.## / #.## (SliceVm = PanVt / SliceVt) and get an error 6, overflow ( the actual line is "SliceVm = Application.Round((PanVt / SliceVt), 2)".
I have tried several options but I just don't get the results without the overflow?
I have set the variables up in "Option Explicit" with Public ****** As Double and have tried Long but still get the error. I can Divide either number by an actual number and it works such as "SliceVm = PanVt / 6.73"
but, when I put them together the error occurs?
I have copied the Option Explicit, and sections of the routines that pertain to the values of the variables. I have also included the full routine of the section I am having issues with. By the way this is the first time I have ever
used Public variables, but I don't think that is an issue here. I have Also made the line with the error in BOLD for you.
Any help would be appreciated. I hope I have done this correctly in your system...
VBA Code:
Option Explicit
Public Calories As Double
Public CaloriesT As Double
Public AreaT As Double ' Variable for Total Area of the Pan
Public SomeVw As Double
Public SomeVl As Double
Public SliceVt As Double ' Variable for Customers Slice Total Area
Public SliceVm As Long ' Variable for the Sum of PanVt / SliceVt
Public PanVt As Double ' Variable for Pan's Total Area Divided by Cust. Slice total area
'-------------------------------------------
Private Sub UserForm_Activate()
' Servings for Rectangles- Form Page
Dim Wn As Integer
Dim Wsn As Integer
Dim Ln As Integer
Dim Lsn As Integer
'ETC.
End Sub
'-------------------------------------------
Private Sub AreaT_txtbox_Change()
Dim SliceVst As Double ' Variable Sub Total
Dim SliceVr As Double
Dim CalVt As Double ' Variable for New CaloriesTotal
Dim CustSw As Double ' Variable for Customers Slice Width
Dim CustSl As Double ' Variable for Customers Slice Length
Dim CaloriesTotal As Double
RectangleShape_txtbox.Visible = True
Rectangle_Inst_txtbox.Visible = True
If (AreaT_txtbox > 0) Then
Call Show_Custom_Slices
Call Show_Middle_Column
'----- Enter Size of Pan in Middle Column -----------------------
Header_Inst2_txtbox.Value = Application.Text(AreaT_txtbox, "###.00") ' Area Total of Rectangle Pan
AreaT = Val(AreaT_txtbox.Value)
ETC.
End Sub
'----------------------------------------------
Private Sub Width_Length_Slice_Fract()
' Calculate for Slices Width & Length
Dim Wfs As Double
Dim Lfs As Double
'--- Converting Width Fractions into Decimals --------------------------------
If (WidthFract_Slice_cobo.ListIndex <> -1) Then
WidthFract_Slice_cobo.Text = (WidthFract_Slice_cobo.List(WidthFract_Slice_cobo.ListIndex))
End If
If (WidthFract_Slice_cobo.Text = "0") Then
Wfs = 0
GoTo ByPass1
End If
If (WidthFract_Slice_cobo.Text = "1/8") Then
Wfs = 0.125
GoTo ByPass1
End If
If (WidthFract_Slice_cobo.Text = "1/4") Then
Wfs = 0.25
GoTo ByPass1
End If
If (WidthFract_Slice_cobo.Text = "3/8") Then
Wfs = 0.375
GoTo ByPass1
End If
If (WidthFract_Slice_cobo.Text = "1/2") Then
Wfs = 0.5
GoTo ByPass1
End If
If (WidthFract_Slice_cobo.Text = "5/8") Then
Wfs = 0.625
GoTo ByPass1
End If
If (WidthFract_Slice_cobo.Text = "3/4") Then
Wfs = 0.75
GoTo ByPass1
End If
If (WidthFract_Slice_cobo.Text = "7/8") Then
Wfs = 0.875
End If
ByPass1:
'--- Converting Length Fractions into Decimals --------------------------------
If (LengthFract_Slice_cobo.ListIndex <> -1) Then
LengthFract_Slice_cobo.Text = (LengthFract_Slice_cobo.List(LengthFract_Slice_cobo.ListIndex))
End If
If (LengthFract_Slice_cobo.Text = "0") Then
Lfs = 0
GoTo ByPass2
End If
If (LengthFract_Slice_cobo.Text = "1/8") Then
Lfs = 0.125
GoTo ByPass2
End If
If (LengthFract_Slice_cobo.Text = "1/4") Then
Lfs = 0.25
GoTo ByPass2
End If
If (LengthFract_Slice_cobo.Text = "3/8") Then
Lfs = 0.375
GoTo ByPass2
End If
If (LengthFract_Slice_cobo.Text = "1/2") Then
Lfs = 0.5
GoTo ByPass2
End If
If (LengthFract_Slice_cobo.Text = "5/8") Then
Lfs = 0.625
GoTo ByPass2
End If
If (LengthFract_Slice_cobo.Text = "3/4") Then
Lfs = 0.75
GoTo ByPass2
End If
If (LengthFract_Slice_cobo.Text = "7/8") Then
Lfs = 0.875
GoTo ByPass2
End If
ByPass2:
'----- Width Slice Custom Size ------------------------------------
SomeVw = WidthNo_Slice_cobo + Wfs 'CDbl = Change to Dim Double
WidthSliceT_txtbox = Application.Text(SomeVw, "# ??/??")
CustInch0w_txtbox = Application.Text(SomeVw, "# ??/??")
'----- Length Slice Custom Size ------------------------------------
SomeVl = LengthNo_Slice_cobo + Lfs
LengthSliceT_txtbox = Application.Text(SomeVl, "# ??/??")
CustInch0l_txtbox = Application.Text(SomeVl, "# ??/??")
'----- Strip 0 - Custom Slice ----------------------
If (WidthSliceT_txtbox > "0") And (LengthSliceT_txtbox > "0") Then
PanVt = Application.Round(AreaT, 2)
SliceVt = Application.Round((SomeVw * SomeVl), 2)
If (PanVt >= SliceVt) Then
[B]SliceVm = Application.Round((PanVt / SliceVt), 2)[/B]
People0_Value_txtbox.Value = Application.RoundDown(SliceVm, 0)
Else
CustInch0w_txtbox = " "
CustInch0l_txtbox = " "
End If
'----- My Testing Textboxes for Results ---------------------
Test1_txtbox = "PanVt = " & PanVt
Test2_txtbox = "SliceVt = " & SliceVt
Test3_txtbox = "SliceVm = " & SliceVm
Test4_txtbox = "# People = " & People0_Value_txtbox
End Sub