Edit listbox values including columns and update the worksheet

spanner28

New Member
Joined
Jul 23, 2024
Messages
4
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I have a listbox from sheet1 with 7columns. I already linked it on textbox. now, I want to modify the existing listbox and sheet1. also, add new items.
can someone help me? i dont know how to proceed.

tried some scripts but it only update 1 column and duplicate it to other cols.

VBA Code:
Private Sub CommandButton1_Click()

ListBox1.ColumnCount = "7"

With ListBox1
    .RowSource = "sheet1!A2:G200"
   
    .ColumnHeads = True
    .ColumnWidths = "80;80;80"
End With

End Sub

Private Sub ListBox1_Click()

  Dim i As Long
    With Me.ListBox1
        i = .ListIndex
   
        Me.TextBox1.Text = .List(i, 0)
        Me.TextBox2.Text = .List(i, 1)
        Me.TextBox3.Text = .List(i, 2)
        Me.TextBox4.Text = .List(i, 3)
        Me.TextBox5.Text = .List(i, 4)
        Me.TextBox6.Text = .List(i, 5)
        Me.TextBox7.Text = .List(i, 6)
       
    End With
   
End Sub

1721791239788.png
 
Last edited by a moderator:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,224,741
Messages
6,180,681
Members
452,993
Latest member
FDARYABEE

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