PDA

View Full Version : VBA Excel Helper Subprocedures;Homework



ladeda16
04-08-2008, 02:12 PM
Recently, i need help with my homework. It's getting really tough and i don't get it. However, I'm in my last section for it. SO YIPPE. I know I've made mistakes that I should of realized. So, i hope mod's or repliers aren't mad at me.

So, here is my cmdSelect button. I think it's more clear, if you see the downloaded attachment, I provided.

Once i clicked the cmdSelect button is that it is not defined. But, i asked my tutor and he told me not define it. I wanted more help from him, but my computer ran out of juice.

So, what the cmdSelect button does, is when a user inputs a product and the type of product into the fields, a msgbox comes up and says thanks for voting. But, it will probably be more clear to you guys, when you look at it.

ladeda16
04-08-2008, 04:17 PM
Help please?

mdmackillop
04-08-2008, 05:40 PM
Where are your code comments? I've no idea what your code is meant to do and I've no time to waste deciphering it. How would you expect to maintain this in a year's time?

Fix your errors one at a time. Comment out offending lines until there are no compile errors, then fix things in turn and step through your code.

"Cells" requires a sheet reference.

Simon Lloyd
04-09-2008, 01:29 AM
To help you test code, Microsoft Visual Basic provides a special window called the Immediate Window. To display the Immediate Window, when you are in the VBE (Visual Basic Editor, use Alt+F11), you can click View -> Immediate Window. Look here (http://www.cpearson.com/excel/Debug.htm) for some help on it. To comment a line (say what the line does) type a ' then your short description, the ' tells excel to ignore this line, so if you have faulty lines of code add a ' in front and excel ignores them, however if you say did this:

'If Range("A1")="d" Then
then you would cause another error because you will have an End IF without an If so as md says comment out further lines until you can compile your code and it shows no error then work on from there!

mdmackillop
04-09-2008, 11:13 AM
Good link Simon.