Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / November 2006

Tip: Looking for answers? Try searching our database.

User form problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Freshman - 06 Nov 2006 04:22 GMT
Dear all,

I follow a book's example which teaches how to transfer the data (Name &
Sex) from an user form onto a spreadsheet. I follow the procedures
step-by-step but when I clicked the "OK" button which executives the transfer
action, a compile error occurred stating "variables not defined" and
highlighted the wording "NextRow =" in the VBA code below. Please kindly
advise what's wrong with the code and how to remedy it. Thanks.

Sheets("Sheet1").Activate
   
   NextRow = _
       Application.WorksheetFunction.CountA(Range("A:A")) + 1
   Cells(NextRow, 1) = TextName.Text
   
   If OptionMale Then Cells(NextRow, 2) = "Male"
   If OptionFemale Then Cells(NextRow, 2) = "Female"
   If OptionUnknown Then Cells(NextRow, 2) = "Unknown"
   
   TextName.Text = ""
   OptionUnknown = True
   TextName.Text.SetFocus
Chip Pearson - 06 Nov 2006 05:34 GMT
If you get a Variable Not Defined error, it means exactly that -- you
haven't declared the variable. At the beginning of the procedure, after the
Sub or Function statement, declare the variable:

Dim NextRow As Long

Signature

Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)

> Dear all,
>
[quoted text clipped - 19 lines]
>    OptionUnknown = True
>    TextName.Text.SetFocus
Freshman - 06 Nov 2006 06:56 GMT
Hi Chip,

Thanks for your help and it works. As I'm just a VBA beginner, please
tolerate my stupid question.

All the best. Regards.

> If you get a Variable Not Defined error, it means exactly that -- you
> haven't declared the variable. At the beginning of the procedure, after the
[quoted text clipped - 25 lines]
> >    OptionUnknown = True
> >    TextName.Text.SetFocus
Chip Pearson - 06 Nov 2006 17:54 GMT
We tolerate all kinds of questions -- we're a nice group of people. As an
aside, you posted your question in the worksheet.function newsgroup. It
would have been more appropriate to post in the programming group, since it
was a programming/VBA related question.

Signature

Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)

> Hi Chip,
>
[quoted text clipped - 35 lines]
>> >    OptionUnknown = True
>> >    TextName.Text.SetFocus
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.