# 更新コード設定検証
Function condition(ByRef objCmb As ComboBox)
If objCmb.Value ="" And objCmb.Value = "g" Then
Call MsgBox("gg", vbOKOnly, "error")
End If
End Function
Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
condition (ComboBox1)
End Sub
'other codes for reference:
Private Sub CommandButton1_Click()
Dim lastrow As Integer
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To 3
For j = 1 To 5
With Me.Controls("ComboBox" & (i - 1) * 5 + j)
If .Text <> "" Then
Cells(lastrow + i, j) = .Text
Else
Exit Sub
End If
End With
Next j
Next i
End Sub
私は、VBAのユーザーパネルで50のコンボやテキストボックスを持っています。すべてのコンボボックスまたはテキストボックスに制約を設定するのは面倒ですので、すべてのコンボボックスおよびテキストボックスに適用する関数が必要です。上記のコードについて
、それが解決するためにどのようにcant find object
エラー
を示して?
Btw、テキストボックスの関数ステートメントを設定する方法は? is Function condition2(ByRef objCmb As textbox)...
あなたはあなたの関数で 'objCmb'を受けています。 'ComboBox'ではなく、それを使用してください。 –
Kenが言っていることは、If ComboBox.Value <> "" ComboBox.Value = "g" Then'を 'If objCmb.Value <>" "と置き換え、objCmb.Value =" g "Then' –
i試してみましたが、 'condition(ComboBox1)'にオブジェクトエラーが見つかりません。 – Monchhichi