Hi everyone.
I'm working on a script for a while know. Everything works fine except that the updating goes very slow.
I use the code below. I have a excel sheet with a range from A8:H282. When i use the update button it takes about 2 second before the new value has been listed and updated.
The other thing is that when the listbox has been loaded the scrollbox is very very long. So it displays the range but i can scroll a lot of white space after the listed range.
Code:
Private Sub UserForm_Initialize()
Dim x As Long
Dim k As Long
Dim j As Long
Dim rng As Range
Set rng = Sheets("INPUT WV LISTBOX").Range("A8:H282")
Rx1 = 8
With ListBox1
.RowSource = ""
For k = 1 To rng.Rows.Count 'rows
For j = 1 To rng.Columns.Count
.AddItem
.List(k - 1, j - 1) = rng.Cells(k, j).Text 'columns
Next j, k
End With
For j = 1 To 8
Me.Controls("TextBox" & j).Text = ""
Next j
End Sub
Update button
Code:
Private Sub CommandButton2_Click()
Dim j As Long
Dim x As Long
If Me.ListBox1.ListIndex = -1 Then
MsgBox "No Data Selected"
Exit Sub
End If
If Me.TextBox1.Value = "" Then Exit Sub
Rx1 = Rx1 + Me.ListBox1.ListIndex 'row index
With Sheets("INPUT WV LISTBOX")
For j = 3 To 8 'columns Start in Column 4 but you wish to NOT change
' columns 4 through 7 so start in Column 8
.Cells(Rx1, j).Value = Me.Controls("TextBox" & j - 0).Text
Next j
End With
Call UserForm_Initialize
End Sub
Bookmarks