ListBox Data Update

nidhipatel

Board Regular
Joined
Feb 11, 2017
Messages
52
my userform1 contain 4 TextBox ,1 listbox, 2 command button
TextBox1
TextBox2
TextBox3
TextBox4

listbox1 contain 4 colmun and head name is Doc No, Date, Center, Rate

command button1 for TextBox Data transfer to listbox1
command button 2 for Update Listbox data

now
suppose i all 4 Textbox data tranfer to listbox1 and i need edit some listbox1 data

1 when i double click any data of listbox1 then those data show in all four textbox
2 after show all data in textbox then data edit and click command button2 for update data
data wil update and show in listbox1
how it made with vba excel macro
 

Attachments

  • ListBox.JPG
    ListBox.JPG
    34.7 KB · Views: 5

Excel Facts

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

Is the listbox showing data from excel sheet on loading of user form ?

Is Doc No. contains unique data ?

-Saurabh
 
Upvote 0
No listbox data didnot show from excel sheet
yes doc number is unique data
From where you are displaying data in Listbox?
After editing the data, where is the data stored which you would like to update ?

To display selected data from Listbox to Textbox you can use below code. (lstDetails is ListBox name)

VBA Code:
Private Sub lstDetails_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
       txtDocNo = lstDetails.List(lstDetails.ListIndex, 0)
       txtDate = CDate(lstDetails.List(lstDetails.ListIndex, 1))
       txtCenter = lstDetails.List(lstDetails.ListIndex, 2)
       txtRate = lstDetails.List(lstDetails.ListIndex, 3)
End Sub


Same code using WITH statement:
VBA Code:
Private Sub lstDetails_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    With lstDetails
       txtDocNo = .List(.ListIndex, 0)
       txtDate = CDate(.List(.ListIndex, 1))
       txtCenter = .List(.ListIndex, 2)
       txtRate = .List(.ListIndex, 3)
    End With
End Sub
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

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