は、私は次のコードのビットを持っているユーザーフォームが含まれています:excel 2010 vbaどのようにリストボックスを宣言できますか?
Private Sub RemoveRecipientCommandButton_Click()
Application.ScreenUpdating = False
Dim intCount As Integer
For intCount = RecipientsListBox.ListCount - 1 To 0 Step -1
If RecipientsListBox.Selected(intCount) Then RecipientsListBox.RemoveItem (intCount)
Next intCount
Application.ScreenUpdating = True
End Sub
このコードは複数選択1であるリストボックス上で実行される - fmMultiSelectMulti、とうまく動作します。パラメータが渡されるようにするときに問題が発生するので、複数のListBoxで同じサブを使用できます。私が試した:
Private Sub RemoveRecipientCommandButton_Click()
Application.ScreenUpdating = False
RemoveSelected (RecipientsListBox)
Application.ScreenUpdating = True
End Sub
を
Private Sub RemoveSelected(LB As ListBox)
Dim intCount As Integer
For intCount = LB.ListCount - 1 To 0 Step -1
If LB.Selected(intCount) Then LB.RemoveItem (intCount)
Next intCount
End Sub
で、私も試してみた:
Private Sub RemoveSelected(LB As MSForms.ListBox)
と
Private Sub RemoveSelected(LB As ListObject)
としてRemoveSelected
コードビーイングの残りの部分と同じ。このコードのこれらの形式はすべてエラー424 - オブジェクトが必要です。私は決してExcelプロではないので、私の主な関心事はここで働くコードを見つけることです - これを、必要ならば、コードを書かなくても複数のListBoxで使用できるものにしたいと思っています各ListBoxで新しい誰かが私を正しい方向に向けることができたら、私が得ることができるすべての助けに感謝します。ありがとう。
Subsを宣言するために 'Private'を使用する場合、それらは同じモジュールまたはuserform-moduleにある必要があります。 –