Solved

Excel 2003 VB Variable used in Controls of user froms.

Posted on 2011-09-22
2
155 Views
Last Modified: 2012-05-12
Hello,

I am creating a user form in Excel that has a number of text boxes that a user enters data into. Some are to be numeric only.  If a user enters non-numeric data in the box there is code to catch that and return a zero value and lets the user know.  Rather than right the code for each box I assign a integer variable to the code on each TextBox and pass that along to a public function that uses that to create a variable representing the TextBox control name.  ie  It takes "TextBox" and combines it with 1, 2, 3, etc and uses that as the control name to run the routine.  It fails please help.  Sample is attached. Text-Box-Variable.xls
0
Comment
Question by:DavidH7470
2 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 36583049
Not sure what you are doing, but perhaps amend module1 to
 If Not IsNumeric(UserForm1.Controls(StrOptName).Value) Then

Open in new window

0
 

Author Closing Comment

by:DavidH7470
ID: 36583099
Great Thank you.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now