Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default User-defined type not defined

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default User-defined type not defined

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

Jim Thomlinson


"cluck" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default User-defined type not defined

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.

"Jim Thomlinson" wrote:

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

Jim Thomlinson


"cluck" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default User-defined type not defined

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

--
HTH...

Jim Thomlinson


"cluck" wrote:

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.

"Jim Thomlinson" wrote:

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

Jim Thomlinson


"cluck" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default User-defined type not defined

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

"Jim Thomlinson" wrote:

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

--
HTH...

Jim Thomlinson


"cluck" wrote:

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.

"Jim Thomlinson" wrote:

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

Jim Thomlinson


"cluck" wrote:

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

Reply
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
"User-defined type not defined" message in Excel RW1946 Excel Discussion (Misc queries) 0 August 31st 05 12:14 PM
Workspace faux user-defined type not defined Chris S[_2_] Excel Programming 3 November 11th 04 05:51 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
User Defined type not defined Karpagam Excel Programming 1 May 16th 04 05:41 PM
Word.Document - user defined type not defined jowatkins[_7_] Excel Programming 0 January 20th 04 08:46 AM


All times are GMT +1. The time now is 03:13 PM.

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

About Us

"It's about Microsoft Excel"