How to get selected data from ListBox into scecific Excel Sheet

MinoMacro

New Member
Joined
May 3, 2019
Messages
3
I have a form where I fill ListBox(lstSearchResults)
0vvQRheGwzDHBV0JeVtUaQCb7Yg6hzQjs-3pmMixK4jm-zh4acIh69c1hVSQuvUU3-_YxFGKtlV_1EEw_R_BAgEph6gBEuOW_s6J4t_PiM-tmSegMxror1fTq_XpteAbhE1DvokymSKUMo8m3yOyOzY7n_7A10ezV8JTJCEtjUvObNKOwT-OdAKd91DYb_6uWuCE0USDMSC6IVlTB7jhaIHYpbCXT24irwcPYf4fDkEl9X6J3a-6ZHro6cnOW38tQ98aq0oRY4AWGNXyy-zSAhQmsa1mAaMxg4qHBHhwIp_tUVHDxrlnVfk7_2iC1tz_5X7NfiDWLARifOteXoUCBEeTBgjr6CqGDdW8ePGW9iky_VMRAfJfaKTsqDC4TSFcwgu0tz0eNZMwnSpSxrlqAwRf6dqtJ2OXH5jVJfSEQQba1KtKIn_pVn87lNRJG4FYnGhyFTMABvaAgRKN8VtAGaod166RJaJMH7jSbVHy4c3iC7kb4XN1SGZnvkCjZnfZZd-OUUD9difxPgqvbrH_QiZpIyhUPLAbSda1EqI_g6CzOiIlIM0Vyl88MuUeKZj4v8ksO5nMa-E9D9PjkAp4STEcMfSy06ulKMbkQP5FQCQu5lkJN22bM00KFs5UVJmvzupb9DtXad50XXPo031U006IpNd6FLYE89deKLzPr29yzGqcBCLEB0yGA50-7srdJ2T4sCYo7qmxddh-l8j0gHn07g=w1267-h546-no

How can I after select one row, transfer data (Client, Name, Surname, Product) into sheet(Vstup) to cells D2,D3,D4,D5?
Can anybody help me, please?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try this


Code:
Private Sub CommandButton1_Click()
    If ListBox1.ListIndex = -1 Then
        MsgBox "Select one row from listbox"
        Exit Sub
    End If
    Range("D2").Value = ListBox1.List(ListBox1.ListIndex, 0)
    Range("D3").Value = ListBox1.List(ListBox1.ListIndex, 1)
    Range("D4").Value = ListBox1.List(ListBox1.ListIndex, 2)
    Range("D5").Value = ListBox1.List(ListBox1.ListIndex, 3)
End Sub
 
Upvote 0
Thank you DanteAmor, great jog :)

I just substitute a names and its realy work, how I expect.

Private Sub Enter_Click()
If lstSearchResults.ListIndex = -1 Then
MsgBox "Select one row from listbox"
Exit Sub
End If
Worksheets("Vstup").Range("D24").Value = lstSearchResults.List(lstSearchResults.ListIndex, 0)
Worksheets("Vstup").Range("D26").Value = lstSearchResults.List(lstSearchResults.ListIndex, 1)
Worksheets("Vstup").Range("D28").Value = lstSearchResults.List(lstSearchResults.ListIndex, 2)
Worksheets("Vstup").Range("D30").Value = lstSearchResults.List(lstSearchResults.ListIndex, 3)
Worksheets("Vstup").Range("D32").Value = Date

Worksheets("VSTUP").Activate
Range("D24").Select
Unload Me
End Sub
 
Upvote 0
Im glad to help you, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,614
Members
449,039
Latest member
Mbone Mathonsi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top