PDA

View Full Version : Help... What have I done !!



james620
06-03-2010, 02:41 PM
Could anyone please help me sort out this vba code? i've got myself tangled in a web of code!!
I have a spreadsheet attached. It has 3 tabs. Tab 1 is the shifts for drivers. it will simply have a number in it indicating what van they are driving. sheet 2 shows daily who is on what van for quick reference, and then sheet 3 is a list of people who are trained in another driving skill.

Basically, I update the first sheet with the van number, the macro then takes the driver's number (the 4 digit bit in col f, and diplays that next to that date and van number.... if that makes sense?

i have put in a load of 1, 2 and 3's I originally wrote the macro (and it worked) having the quick reference bit at the top, all on 1 sheet... but since re-writing it (and this being my first vba project... i dont think ive done too badly!!!) it seems to have all gone wrong....

Any help to either fix or simply the code would be very much appreciated...

James
:banghead:

austenr
06-03-2010, 05:25 PM
I looked at your code. A couple of thoughts that might help you.

Right after you declare your Sub put this:

Application.ScreenUpdating = False

at the end of your sub put the same as above only set it to False. This will stop your screen from flickering.

Secondly, in the VBE (Visual Basic Editor) go to Tools>Options then check the Variable Declaration box. This will put Option Explicit at the top of every module you create.

After you do the above steps try to debug it. Start first by trying to compile it. It will not compile cleanly. Thats because you have undeclared variables which is part of your problem.

Also your code seems to be in a loop. Try to copy and paste your module code and post it here in the forum using the VBA code tags. This will help anyone wanting to help you to try to see obvious coding errors.

Try to get it as far as you can fixing the errors and then post it. Try to fix your undeclared variables and make sure for every For statement you have a corresponding Next. Placement of these is critical.

Once you get the Option Explicit set up it will help you so much in debugging.

Don't mean to ramble on, just trying to help you get on the right path. We've all been there. :hi: