PC Review


Reply
Thread Tools Rate Thread

Add User from a UserForm

 
 
=?Utf-8?B?Q2hyaXM=?=
Guest
Posts: n/a
 
      15th Nov 2006
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      15th Nov 2006
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:
if found > 1 then
Sheet2.Range("H" & found).Value = UserForm1.TextBox9.Value
else
Sheet2.Range("H" & Test_Row).Value = UserForm1.TextBox9.Value
End if
ComboBoxRefresh

End Sub

--
Regards,
Tom Ogilvy

"Chris" wrote:

> 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
>

 
Reply With Quote
 
=?Utf-8?B?Q2hyaXM=?=
Guest
Posts: n/a
 
      15th Nov 2006
Wahoo! That worked thanks!

"Tom Ogilvy" wrote:

> 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:
> if found > 1 then
> Sheet2.Range("H" & found).Value = UserForm1.TextBox9.Value
> else
> Sheet2.Range("H" & Test_Row).Value = UserForm1.TextBox9.Value
> End if
> ComboBoxRefresh
>
> End Sub
>
> --
> Regards,
> Tom Ogilvy
>
> "Chris" wrote:
>
> > 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
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm and user input RHall Microsoft Excel Programming 2 12th Feb 2008 05:49 PM
Log User Name and Date when userform was run/modified Corey Microsoft Excel Programming 1 21st Nov 2006 04:17 AM
Asking user to pick a file name in userform... Trevor Microsoft Excel Programming 1 13th Mar 2004 01:36 AM
Re: How to keep a Userform available while the user interacts with a spreadsheet Tom Ogilvy Microsoft Excel Programming 1 10th Sep 2003 01:26 PM
Re: How to get User input from Userform Text box K Microsoft Excel Programming 1 9th Sep 2003 10:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:41 AM.