User-defined type not defined

C

cluck

I have a button on a user form that after entering data when clicked should
enter the data at the bottom of a list in Excel.
However when I attempt to run the code I get a "User-defined type not
defined".
What am I doing wrong?


Private Sub fAdd_Click()
Dim NewRow As Interger ' HERE is where the error is highlighted.
NewRow = Worksheets("main").Range("a1").Value + 1

If Len(MyForm.fname.Value) = 0 Then
MsgBox "The name field cannot be left empty", vbOKOnly, ""
MyForm.fname.SetFocus
Exit Sub
End If

Worksheets("table").Cells(NewRow, 1).Value = MyForm.fname.Value
Worksheets("table").Cells(NewRow, 2).Value = MyForm.fSocial.Value

MyForm.Hide

End Sub
 
J

Jim Thomlinson

As a guess you did not mean Interger <sp>, but rather Integer. As a guess you
type like I do. It may be more appropraite to use long however since integer
only goes to 32K while there are 65k rows...
 
C

cluck

Thanks Jim, It was my "fat" fingers causing that problem.
Now I'm receiving a "type mismatch" on the very next line of code.
Forgive me, but I'm fairly new at VB.
 
J

Jim Thomlinson

Guessing here, but I assume that newRow is intended to be the first blank row
in the spreadsheet? If so then the trick is to come at it from the bottom up
something like this...

NewRow = Worksheets("main").cells(rows.count, "A").end(xlUp).offset(0,1).row
 
C

cluck

Good Guess. I suppose I didn't explain myself very well.
THanks that was what I needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top