LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Select Case and If...Then Statements in UserForm not Calculating

I am building a product quoting system in VBA for my company that
manufactures outdoor plastic sign faces. I have a Userform with 6 text
boxes, 1 combobox, command button:

tbxDimHft1 = user enters Height of sign in feet
tbxDimHins1 = user enters Height of sign in inches
tbxDimWft1 = user enters Width of sign in feet
tbxDimWins1 = user enters Width of sign in inches
tbxCalculatedPrice = shows calculated price when command button is clicked
tbxQuotePrice = shows quote price when command button is clicked
cboMaterial = contains material for signs
cmbCalculate = command button to run calculation code

In my current code tbxCalculatedPrice and tbxQuotePrice should equal the
same, but for some reason they are not equalling each other when I click the
Calculate Button. For example, if I enter the following data:

tbxDimHft1 = 4
tbxDimHins1 = 0
tbxDimWft1 = 3
tbxDimWins1 = 0
cboMaterial = "Clear .150 High Impact Modified Acrylic"

Click the command button

tbxQuotePrice = 32.76
tbxCalculatePrice = 47.00

WHY???? Any help would be greatly appreciated, because I have looked at
this forever and cannot see why the calculations are not the same. THANKS!!

Note: PL509 = $9.36

Private Sub cmbCalculate_Click()

Dim Height As Long, Width As Long
Dim MaxL As Long, MinL As Long
Dim material As Long

Height = tbxDimHft1 + (tbxDimHins1 / 12)
Width = tbxDimWft1 + (tbxDimWins1 / 12)

MaxL = WorksheetFunction.Max(Height, Width)
MinL = WorksheetFunction.Min(Height, Width)

Sheets("Parts List").Activate

''''''''''''calculated price text box''''''''''''''''''''''''
Select Case cboMaterial.Text

Case "Clear .150 High Impact Modified Acrylic"

If MaxL <= 4 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL509", Range("A:D"), 4, False)
If 4 < MaxL <= 6 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL505", Range("A:D"), 4, False)

Case "Clear .150 Polycarbonate"

If MaxL <= 4 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL522", Range("A:D"), 4, False)
If 4 < MaxL <= 6 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL524", Range("A:D"), 4, False)

Case "White .150 High Impact Modified Acrylic"

If MaxL <= 4 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL510", Range("A:D"), 4, False)
If 4 < MaxL <= 6 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL506", Range("A:D"), 4, False)

Case "White .150 Polycarbonate"

If MaxL <= 4 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL521", Range("A:D"), 4, False)
If 4 < MaxL <= 6 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL529", Range("A:D"), 4, False)

Case "Clear .177 High Impact Modified Acrylic"

If MaxL <= 8 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL503", Range("A:D"), 4, False)

Case "White .177 High Impact Modified Acrylic"

If MaxL <= 8 Then material = (MinL + 0.5) *
WorksheetFunction.VLookup("PL504", Range("A:D"), 4, False)

End Select

tbxCalculatedPrice = material

'''''''''''''quote price textbox value''''''''''''''''''''
If MaxL <= 4 And cboMaterial.Text = "Clear .150 High Impact Modified
Acrylic" Then tbxQuotePrice = (MinL + 0.5) *
WorksheetFunction.VLookup("PL509", Range("A:D"), 4, False)

Sheets("Quote").Activate

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statements to Select Case??? Walter Excel Discussion (Misc queries) 2 December 2nd 09 08:00 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Select Case Statements Al@n[_2_] Excel Programming 6 July 3rd 07 05:26 PM
Using Select Case Statements Bob[_53_] Excel Programming 3 April 30th 04 08:58 PM


All times are GMT +1. The time now is 06:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"