03. marts 2014 - 14:26Der er
13 kommentarer og 1 løsning
If sætninger i Excel 2010
If Val(Textbox1.Value) = 14 Or 14.5 Or 11.5 Or 13.5 Or 17 Then Textbox2.Value = Textbox1.Value + 2 End If If Val(Textbox1.Value) = 21 Or 24 Or 30 Or 32 Or 33 Or 34 Or 36 Or 25 Or 26 Or 27 Or 29 Or 37 Or 40.5 Then Textbox2.Value = Textbox1.Value + 4 End If
Obs. ved øvrige værdier skal textbox1.value være ""
Prøv med dette princip: Private Sub Test() v = Val(TextBox2) If v = 14 Or v = 14.5 Or v = 11.5 Or v = 13.5 Or v = 17 Then TextBox2.Value = TextBox1.Value + 2 End If .. ..
For at få decimaltal med: Private Sub Test() Dim v As Double v = TextBox2.Value If v = 14 Or v = 14.5 Or v = 11.5 Or v = 13.5 Or v = 17 Then TextBox2.Value = TextBox1.Value + 2 End If
If Val(Textbox1.Value) = 14 Or 14.5 Or 11.5 Or 13.5 Or 17 Then Textbox3.Value = Textbox2.Value + 2 End If If Val(Textbox1.Value) = 21 Or 24 Or 30 Or 32 Or 33 Or 34 Or 36 Or 25 Or 26 Or 27 Or 29 Or 37 Or 40.5 Then Textbox3.Value = Textbox2.Value + 4 End If Obs. ved øvrige værdier (textbox1) skal textbox3.value være ""
Nej, det har jeg ikke, men det skal fungere på flg. måde:
Værdien i textbox1 kommer fra en anden textbox. Værdien i textbox2 kommer også fra en anden textbox/kan tastes ind /eller rettes i. Textbox3 er locked. Håber det giver mening.
Private Sub TextBox1_Change() beregnTekstboks3 End Sub Private Sub TextBox2_Change() beregnTekstboks3 End Sub Private Sub beregnTekstboks3() Dim v1 As Double If IsNumeric(Me.TextBox1) = True And _ IsNumeric(Me.TextBox2) = True Then
v1 = TextBox1.Value
Select Case v1 Case 14, 14.5, 11.5, 13.5, 17 TextBox3.Value = TextBox2.Value + 2
Case 21, 24, 30, 32, 33, 34, 36, 25, 26, 27, 29, 37, 40.5 TextBox3.Value = TextBox2.Value + 4 Case Else TextBox3.Value = "" End Select Else TextBox3.Value = "" End If End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.