Thread: Error 381
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 1,726
Default Error 381

This sounds as if the range being loaded is empty. Chek the data on that
sheet, that range.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
wrote in message
ups.com...
I am trying to use some code I found for a more advance dataentry
userform and I receive a 381 error when I try to show the userform. The
problem is from the .List under the initialization sub.

Any idea how to resolve this?


Private Sub UserForm_Initialize()
With Me.ListBox1
.List = Sheets("Hoja1").Range("A1").CurrentRegion.Resize(, 1).Value
.MultiSelect = 2
End With
End Sub



Private Sub CommandButton1_Click()
Dim i As Integer, a(), n As Integer
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
n = n + 1
a(n) = .List(i)
End If
Next
End With
If n 0 Then
With Sheets("Hoja1").Range("a" & Rows.Count).End(xlUp).Offset(1)
.Resize(n).Value = WorksheetFunction.Transpose(a)
.Offset(, 1).Resize(n).Value = Me.TextBox1.Text
End With
End If
End Sub