View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_4_] Dick Kusleika[_4_] is offline
external usenet poster
 
Posts: 595
Default Frustrated with learning add command code...

On Wed, 30 Jul 2008 12:56:17 -0700, Stacy
wrote:


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.


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.


If you just use Worksheets, the program will assume youi mean a worksheet in
the active workbook. Whichever workbook you have active does not have a
sheet called PersonalInfoUpdate in it. If the userform is in the same
workbook as the data, use

ThisWorkbook.Workseets(...

otherwise, name the workbook specifically

Workbooks("MyBook.xls").Worksheets(...

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



I don't see the checkbox code in here.

ws.Cells(lRow,10).Value = IIf(Me.cbxSafety.Value, "x","")
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com