Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default User Defined Type not Defined

Thanks Dave - once again. the Option Explicit work wonders. Apparently I was
way too tiered for this yesterday and should have just left it alone. Many
cudos to you for all your assistance with this project.

Carrie

Dave Peterson wrote:
Add this line to the top of your userform module:

Option Explicit

This will make you declare your variables. It would have caught the typo (one
vs ell) and the typo with TestBox vs TextBox.

Option Explicit
Private Sub CommandButton1_Click()
Dim LastRow As Range
Dim Response As Long

Set LastRow = Keys.Range("b65536").End(xlUp)

LastRow.Offset(1, 0).Value = TextBox1.Text

MsgBox "Record written to Training List"

Response = MsgBox("Do you want to enter another record?", vbYesNo)

If Response = vbYes Then
TextBox1.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
End Sub

Here is the code I got from the Microsoft site for "How to Use a UserForm for
Entering Data" But I cannot get the code to work. I get a compile error, User

[quoted text clipped - 26 lines]
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default User Defined Type not Defined

It may seem like more work to have to declare your variables. But I bet you
spent more time searching for the problem than you would have spent declaring
the variables.

If you want to make "Option Explicit" show up in every new module, you can use:
Open the VBE
Tools|Options|Check Require Variable Declaration



"Carrie_Loos via OfficeKB.com" wrote:

Thanks Dave - once again. the Option Explicit work wonders. Apparently I was
way too tiered for this yesterday and should have just left it alone. Many
cudos to you for all your assistance with this project.

Carrie

Dave Peterson wrote:
Add this line to the top of your userform module:

Option Explicit

This will make you declare your variables. It would have caught the typo (one
vs ell) and the typo with TestBox vs TextBox.

Option Explicit
Private Sub CommandButton1_Click()
Dim LastRow As Range
Dim Response As Long

Set LastRow = Keys.Range("b65536").End(xlUp)

LastRow.Offset(1, 0).Value = TextBox1.Text

MsgBox "Record written to Training List"

Response = MsgBox("Do you want to enter another record?", vbYesNo)

If Response = vbYes Then
TextBox1.Text = ""
TextBox1.SetFocus
Else
Unload Me
End If
End Sub

Here is the code I got from the Microsoft site for "How to Use a UserForm for
Entering Data" But I cannot get the code to work. I get a compile error, User

[quoted text clipped - 26 lines]
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200802/1


--

Dave Peterson
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 error Chip Pearson Excel Programming 0 December 7th 06 07:09 PM
"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
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 11:38 PM.

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"