View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chris Chris is offline
external usenet poster
 
Posts: 788
Default Add User from a UserForm

I'm trying to add a user via an UserForm. I've been using this code for
ComboBoxes but it errors out for my textbox. When it runs, the error message
is

"Run-time error '1004': Method 'Range' of object '_Worksheet' failed"
The debugger points to this line
Sheet2.Range("H" & found).Value = UserForm1.TextBox9.Value

I can't find out why 'found' doesn't have a value. Any thoughts. The full
code is below.



Private Sub CommandButton12_Click()

'Add new user

test_row = 2
test_value = Sheet2.Range("H" & test_row).Value

While test_value < ""
If test_value = UserForm1.TextBox9.Value Then
found = test_row
GoTo leaveloop1
End If
test_row = test_row + 1
test_value = Sheet2.Range("H" & test_row).Value
Wend

leaveloop1:

Sheet2.Range("H" & found).Value = UserForm1.TextBox9.Value

ComboBoxRefresh

End Sub