new to macros – extracting data

10 pts.
Tags:
Excel macros
Macros
Microsoft Excel
VBA
Hello, I'm just learning how to use macros and have this fairly large project to do. It concerns extracting data from a schedule (timetable) with the courses, course code, name of tutor on it. I have managed to extract from a cell and have the following information come up in a message box(course code, course title, tutor name. However, what I would like to do is just firstly select those cells by the course code. That is the course code usually follows this form CFR-2101, that is three letters in capitals followed by a dash and 4 numbers. I'm trying to create a user form where the user would have to type in the course code and if the code doesn't follow this form (the 3 letters-and 4 numbers, that a message pops up saying that the course code form is incorrect or something like this. econdly, based on this form of the course code, I would like o be able to highlight those cells in the timetable which start with a course code(eg put then in red or something). My problem is I don't knwo what to put to stand for the course codeie I have tried just * eg.***-**** as the form f the code to recognise but it doesn't work. I'm not to sure how to write in VBA the fact that the code must have this form, containing both letter and numbers. Thanks for your help in advance Barbara

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you want to check if a textbox input is of the format you want, try something like this:

If Len$(TextBox1.Text) <> 8 Then: Exit Sub ‘ right number of characters
If Not Left$(TextBox1.Text, 3) Like “*[abcdefghijklmnopqrstuvwxyz]*” Then: Exit Sub ‘ first three chars are letters
If Not Right$(TextBox1.Text, 4) Like “*[0123456789]*” Then: Exit Sub ‘ last four chars are numbers

Assuming the textbox is called TextBox1 (which I would never do).
–JP

This <a href=”http://www.geocities.com/WallStreet/9245/”>site</a> has some tutorials I’ve found helpful. you might also want to check <a href=”http://www.helpwithpcs.com/tipsandtricks/microsoft-excel-macro-tutorial.htm”>here</a> and <a href=”http://www.tutorialized.com/tutorials/MS-Excel/Macros/1″>here</a>
Good Luck!
-Flame
******************************

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following