Well the error message is telling you that the parser cannot find an end if closing off an if statement. That also includes else if.
So go through each if statement and make certain there is a closing end if. The only time you dont need to use end if is if you use the frowned on but legal one line statement
. Vba zealots would probably insist that you use the conventional syntax
if <boolean expression> then <do something>
The error applies to other block statement structures such as while and do while.
If <boolean expression> then
Having a quick skim through your code i'm uspicious of the ' else if R9'. Youve used code indentation which goes a large way to identjfy these glitches, so the fact youve use end, as opposed to end if AND the end statement is not aligned raises warning flags to me
Im also suspicious of tge commentated out end after the first while statement. When writing long winded block constructs i often comment them eg
...saves a shed load of time in code review
If usergroup = 'developer' then 'special case show debug message
Elseif userid = 'blah'
Endif ' end usergroup block
' or sometime i repeat the if statement as a comment
End if 'if usrrgroup ='developer'
I'd recommend that you stick to a maximum line length so code doesnt spill over several lines.. this may not be a problem in the vba editor but one of the reasons is when posting in forums its messy..
The vba parser doesnt care about such nicities, you could stick all in one line or one word per line
.Body = 'a long winded piece of text' & vbcrlf _
& 'another line of text that spans more than,' _
& ' say 80 characters' _
& ' still the same line droning on.' _
Theres nothing legal about this, its about style. Trying to make code look easier to read. So continuations of the line of code appear aligned under the first token to the right of the = sign. And code diesnt overflow. I find if code is formed inthis manner its an easy patterning approach that nakes it easier to visualise code blocks. Makes it easier for tired eyes to see the wood from the trees
In terms of style note i use the &, string concatenation symbol, &, at the start of a vba line, if a space is needed its the first character of that vba line
Last edited by healdem; 01-16-16 at 03:38.
I'd rather be riding on the Tiger 800 or the Norton