1

次のように、さまざまなデータとデータが配置されている行番号が入力された ListBox があります。

2012 年 3 月 31 日~2012 年 4 月 15 日 [商品 A]、行:12009

コマンド ボタンでは、クリックするとユーザーが特定の行に移動するコードを記述する必要があります。列は常に列 2 に固定されます

4

1 に答える 1

1

If something is selected in the listbox it will find the value after the colon (:) and select column 2 of that row number:

Private Sub CommandButton1_Click()
    Dim selectedItem As String
    If ListBox1.ListIndex <> -1 Then
        selectedItem = ListBox1.List(ListBox1.ListIndex)
        Cells(CInt(Mid(selectedItem, InStrRev(selectedItem, ":") + 1)), 2).Activate
    End If
End Sub
于 2013-03-08T17:28:01.657 に答える