Home > Software engineering >  Why I want to consult a great god, and in the VBA list box to add data can join
Why I want to consult a great god, and in the VBA list box to add data can join

Time:10-14

Create a userform, then add the following code
Private Sub UserForm_Load ()
With Sheet1. ListBox1
The AddItem "Paris"
The AddItem "New York"
The AddItem "London"
The load Cells (3, 1)="suc"
End With
End Sub
It's no use running

Private Sub UserForm_Load ()
ListBox1. AddItem "Paris"
ListBox1. AddItem "New part that goes from the
"ListBox1. AddItem "San Francisco"
ListBox1. AddItem "Chicago"
ListBox1. AddItem "Seattle"
ListBox1. AddItem "Toronto"
ListBox1. AddItem "New York"
ListBox1. AddItem "Tbilisi
"ListBox1. AddItem "Moscow"
ListBox1. AddItem "Portland"
'a pair of selected item,
ListBox1. Selected (0)=True
ListBox1. Selected (1)=True
The load Cells (2, 1)="suc"
End Sub

Running is no use, please help to look at, thank you!!!!!!!!!!

CodePudding user response:

The first piece of code reference:
 Private Sub UserForm_Activate () 
With Sheet1. ListBox1
The AddItem "Paris"
The AddItem "New York"
The AddItem "London"
Sheet1. Cells (3, 1)="load suc"
End With
End Sub


The next piece of code: (vba form without UserForm_Load events)
 Private Sub UserForm_Activate () 
Sheet1. ListBox1. AddItem "Paris"
Sheet1. ListBox1. AddItem "New part that goes from the
"Sheet1. ListBox1. AddItem "San Francisco"
Sheet1. ListBox1. AddItem "Chicago"
Sheet1. ListBox1. AddItem "Seattle"
Sheet1. ListBox1. AddItem "Toronto"
Sheet1. ListBox1. AddItem "New York"
Sheet1. ListBox1. AddItem "Tbilisi
"Sheet1. ListBox1. AddItem "Moscow"
Sheet1. ListBox1. AddItem "Portland"
'a pair of selected item,
Sheet1. ListBox1. Selected (0)=True
Sheet1. ListBox1. Selected (1)=True
Sheet1. Cells (2, 1)="load suc"
End Sub
  •  Tags:  
  • VBA
  • Related