New Member
June 8, 2020
Hi,
I am learning VBA 'on-the-fly' and have been making painfulprogress so far but now am stumped. My code refuses to compile.
If anyone can spot any errors I would be very grateful for assistance or even just steers to where I can do more research. I check Youtube videos and also contributions from experts but have not yet found a solution.
A sincere thank you to you all anyway, even the hope of help gives me inspiration to try again.
October 5, 2010
Hi Pat,
There's a few things there that need fixing up.
You have an IF statement with lots of OR conditions and these conditions are carried over onto multiple lines. To do this in VBA you need to end the line with a space and an underscore e.g.
If (CDate(Cells(i, 4)) >= CDate(Me.TextBox1) _
every line that is continued onto the net line must have a space and underscore.
You have several Subs declared and every one must have an End Sub statement to mark the end of the code for that sub.
Sub commandbutton1_click() has a matching End Sub but after this End Sub is a statement message = "Ready to print" which can't go there, it must be in a Sub.
After that is Private Sub commandbutton2_click() which has no End Sub.
There are a couple of places where you are referencing Range("A10:Ja"). This should be Range("A10:J" & a)
Also, I'd recommend you use the Option Explicit statement at the top of every code module so you are forced to declare variables. It can prevent errors creeping into your code.
Please read these posts which should help you
https://www.myonlinetraininghu.....g-vba-code
https://www.myonlinetraininghu.....ugging-vba
Regards
Phil
1 Guest(s)