LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Frustrated with learning add command code...

I have completed a userform with the following fields:

FirstName LastName Phone Email Address City State Zip

I would like to have a command button that adds these to my worksheet.

I would also like to add check boxes so they can select any initerests they
may have like transportaion, schools, safety. These can show up as an x in
the cell if selected and blank if not.

I have read and reread posts, help, goolgled them all and am still having
trouble learning how to do this. Can anybody help me with the code, or
point me to example add command codes?

I have pasted the only thing I can find with my changes below, but it does
not work and I don't know what I am doing it is just a mess.

Thanks!

Private Sub cmdAdd_Click()

Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PersonalInfoUpdate") ****getting runtime error "9"
subscript out of range error here.
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row


'copy the data to the database
ws.Cells(iRow, 1).Value = Me.txtFirstName.Value
ws.Cells(iRow, 2).Value = Me.txtLastName.Value
ws.Cells(iRow, 3).Value = Me.txtPhone.Value
ws.Cells(iRow, 4).Value = Me.txtEmail.Value
ws.Cells(iRow, 5).Value = Me.txtAddress.Value
ws.Cells(iRow, 6).Value = Me.txtCity.Value
ws.Cells(iRow, 7).Value = Me.txtState.Value
ws.Cells(iRow, 8).Value = Me.txtZip.Value


'clear the data
Me.txtFirstName.Value = ""
Me.txtLastName.Value = ""
Me.txtPhone.Value = ""
Me.txtEmail.Value = ""
Me.txtAddress.SetFocus
Me.txtCity.Value = ""
Me.txtState.Value = ""
Me.txtZip.Value = ""

End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
So frustrated! Please help! Please HELP! Excel Discussion (Misc queries) 2 October 5th 09 05:01 PM
Frustrated onedeviousmale New Users to Excel 6 June 28th 09 08:51 PM
command code ( GOTO command) in formula calan New Users to Excel 1 June 11th 09 09:44 AM
Frustrated Professor frustrated Professor[_2_] Excel Worksheet Functions 2 November 14th 07 05:54 PM
Shell Command : Extremely Frustrated JOHN Excel Programming 2 December 1st 04 02:51 PM


All times are GMT +1. The time now is 10:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"