- 帖子
- 49
- 主題
- 8
- 精華
- 0
- 積分
- 63
- 點名
- 0
- 作業系統
- windows XP
- 軟體版本
- Office 2003
- 閱讀權限
- 20
- 性別
- 女
- 來自
- 高雄
- 註冊時間
- 2013-4-8
- 最後登錄
- 2013-10-30

|
[發問] 執行後出現"執行階段錯誤'13':型態不符 "問題排除
Userform 裡的ComboBox 1,點選單號後會自動帶出TextBox2~TextBox8的資料,並計算TextBox26及TextBox27數值,再點選OptionButton1後自動計算 TextBox21及 TextBox22的值按下CommandButton1後 資料有寫入我要的工作表內,但會出現"執行階段錯誤'13':型態不符", 找很久,仍不知道問題是出在哪裡? 請高手幫忙.
Private Sub ComboBox1_Change()
Dim flag As Boolean
Dim Rowcnt2, x2 As Integer
Dim first, second, user_price As Variant
flag = False
Rowcnt2 = Sheets("analysis").Cells(1, 1).CurrentRegion.Rows.Count
For x2 = 1 To Rowcnt2
If Sheets("analysis").Cells(x2, 1) = UserForm2.ComboBox1.Value Then
TextBox2 = Sheets("analysis").Cells(x2, 2)
TextBox5 = Sheets("analysis").Cells(x2, 7)
TextBox6 = Sheets("analysis").Cells(x2, 4)
TextBox3 = Sheets("analysis").Cells(x2, 5)
TextBox4 = Sheets("analysis").Cells(x2, 6)
TextBox7 = Sheets("analysis").Cells(x2, 8)
TextBox8 = Sheets("analysis").Cells(x2, 9)
flag = True
End If
Next
TextBox26.Value = TextBox8.Value - TextBox7.Value
TextBox27.Value = TextBox26.Value / TextBox8.Value
End Sub
Private Sub OptionButton1_Click()
Dim price_min, ratio, diff As Variant
If OptionButton1 = True Then
If TextBox15.Value = "" And TextBox18.Value = "" Then
price_min = TextBox12.Value
ElseIf TextBox15.Value <> "" And TextBox18.Value = "" Then
price_min = Application.Min(TextBox12.Value, TextBox15.Value)
Else
price_min = Application.Min(TextBox12.Value, TextBox15.Value, TextBox18.Value)
End If
diff = TextBox12.Value - price_min
ratio = diff / TextBox7.Value
TextBox21.Value= diff
TextBox22.Value = ratio
Else
TextBox21.Text = ""
TextBox22.Text = ""
End If
End Sub |
|