Thread
:
shortening a macro
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett[_4_]
external usenet poster
Posts: 2,337
shortening a macro
Have a look at select case
Select Case performance
Case 1
Bonus = salary * 0.1
Case 2, 3
Bonus = salary * 0.09
Case 4 To 6
Bonus = salary * 0.07
Case Is 8
Bonus = 100
Case Else
Bonus = 0
End Select
range("k8")=bonus
--
Don Guillett
SalesAid Software
"Aksel Børve" wrote in message
...
Anyone who can help me write the macro below a little shorter.
MVH Aksel
Private Sub ComboBox1_Change()
Application.ScreenUpdating = False
Sheets("Sheet1").Unprotect
If ComboBox1.Value = "NONE" Then
With Me.Range("K8")
.FormulaR1C1 = ""
With Me.Range("M8")
.FormulaR1C1 = ""
End With
End With
Else
If ComboBox1.Value = "2 7/8'" Then
With Me.Range("K8")
.FormulaR1C1 = "0,0145"
With Me.Range("M8")
.FormulaR1C1 = "0,0123"
End With
End With
Else
If ComboBox1.Value = "4'" Then
With Me.Range("K8")
.FormulaR1C1 = "0,0348"
With Me.Range("M8")
.FormulaR1C1 = "0,0177"
End With
End With
Else
If ComboBox1.Value = "5 7/8'" Then
With Me.Range("K8")
.FormulaR1C1 = "0,0839"
With Me.Range("M8")
.FormulaR1C1 = "0,0298"
End With
End With
Else
If ComboBox1.Value = "4'HW" Then
With Me.Range("K8")
.FormulaR1C1 = "0,0209"
With Me.Range("M8")
.FormulaR1C1 = "0,0333"
End With
End With
Else
If ComboBox1.Value = "5 7/8'HW" Then
With Me.Range("K8")
.FormulaR1C1 = "0,051"
With Me.Range("M8")
.FormulaR1C1 = "0,0686"
End With
End With
Else
If ComboBox1.Value = "DC" Then
With Me.Range("K8")
.FormulaR1C1 = ""
With Me.Range("M8")
.FormulaR1C1 = ""
End With
End With
Else
If ComboBox1.Value = "6 3/4'DC" Then
With Me.Range("K8")
.FormulaR1C1 = "0,0252"
With Me.Range("M8")
.FormulaR1C1 = "0,0948"
End With
End With
Else
If ComboBox1.Value = "8'DC" Then
With Me.Range("K8")
.FormulaR1C1 = ""
With Me.Range("M8")
.FormulaR1C1 = ""
End With
End With
Else
If ComboBox1.Value = "8 1/4'DC" Then
With Me.Range("K8")
.FormulaR1C1 = "0,0287"
With Me.Range("M8")
.FormulaR1C1 = "0,1596"
End With
End With
Else
If ComboBox1.Value = "8 3/4'DC" Then
With Me.Range("K8")
.FormulaR1C1 = ""
With Me.Range("M8")
.FormulaR1C1 = ""
End With
End With
Else
If ComboBox1.Value = "9 3/4'DC" Then
With Me.Range("K8")
.FormulaR1C1 = "0,2456"
With Me.Range("M8")
.FormulaR1C1 = "0,2743"
End With
End With
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
With Me.Range("J24")
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
Reply With Quote
Don Guillett[_4_]
View Public Profile
Find all posts by Don Guillett[_4_]