View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Clarification please...

There are two styles of if statements.

One logical line and multiple logical lines (block form).

your example is really one logical line--it has the line continuation characters
(space underscore) trailing the True.

if a = b then c = d

if a = b then
c = d
end if

My personal preference is to use the multiple line version--except on almost
trivial code where it's easily seen.

But at my age, I'll sometimes miss those continuation characters and I get
confused.

Next time you're in the VBE, highlight an If and hit F1. You'll see a couple
examples.



JMay wrote:

I thought there was this rule where if you use the "If" keyword
somewhere afterwards one had to follow-up with the "End If" phrase.
Obviously not. Maybe the rule only applies in a Standard module
and not a class module like below. Can someone clarify?
Thanks in advance..

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If ThisWorkbook.Sheets("Sheet1").Range("A1").Value < True _
Then Cancel = True
End Sub


--

Dave Peterson