ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile error (https://www.excelbanter.com/excel-programming/425466-compile-error.html)

Basta1980

Compile error
 
Hi,

I get a 'compile error: Block if without end if' when executing this code;


Private Sub CommandButton1_Click()

If CheckBox1 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox20 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox21 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox19 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox20 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox21 Then
Range("Low") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If

End Sub

What to do?!

Thnx in advance

Basta

Nigel[_2_]

Compile error
 
Nothing wrong with this code!

--

Regards,
Nigel




"Basta1980" wrote in message
...
Hi,

I get a 'compile error: Block if without end if' when executing this code;


Private Sub CommandButton1_Click()

If CheckBox1 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox20 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox21 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox19 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox20 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox21 Then
Range("Low") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If

End Sub

What to do?!

Thnx in advance

Basta



Chip Pearson

Compile error
 
You code looks fine to me and it compiled correctly. What line is
giving you the error?


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 12 Mar 2009 08:03:02 -0700, Basta1980
wrote:

Hi,

I get a 'compile error: Block if without end if' when executing this code;


Private Sub CommandButton1_Click()

If CheckBox1 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox20 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox21 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox19 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox20 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox21 Then
Range("Low") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If

End Sub

What to do?!

Thnx in advance

Basta


[email protected][_2_]

Compile error
 
Um.

I recommend putting Option Explicit at the top of the module.

It looks like CheckBox1 and those other variables arent' defined.

So the syntax checker is fussing over "CheckBox1 And CheckBox16 And
CheckBox19" which it is not recognizing as a single boolean
expression.

CheckBox1 might be a dropdown instead of a Boolean.

One other thing. I think you want:

Range("Urgent").value = 1

But that's not related to the compile error.

You might consider changing all those if statements to a select-case
statement.

That's a matter of personal preference.



If CheckBox1 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1


Basta1980

Compile error
 
Chip,

Private Sub CommandButton1_Click() is yellow and the End sub is blue. I even
added the option explicit like gimme_this advised but doenst stop the macro
f'rom hanging up.

"Chip Pearson" wrote:

You code looks fine to me and it compiled correctly. What line is
giving you the error?


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 12 Mar 2009 08:03:02 -0700, Basta1980
wrote:

Hi,

I get a 'compile error: Block if without end if' when executing this code;


Private Sub CommandButton1_Click()

If CheckBox1 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox20 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox21 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox19 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox20 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox21 Then
Range("Low") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If

End Sub

What to do?!

Thnx in advance

Basta



Dave Peterson

Compile error
 
Maybe it's in the other code surrounding this procedure. You may want to look
at that stuff.

Basta1980 wrote:

Hi,

I get a 'compile error: Block if without end if' when executing this code;

Private Sub CommandButton1_Click()

If CheckBox1 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox20 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox17 And CheckBox21 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox19 Then
Range("High") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox20 Then
Range("Medium") = 1
End If
If CheckBox1 And CheckBox18 And CheckBox21 Then
Range("Low") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox19 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox20 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox16 And CheckBox21 Then
Range("Urgent") = 1
End If
If CheckBox2 And CheckBox17 And CheckBox19 Then
Range("Urgent") = 1
End If

End Sub

What to do?!

Thnx in advance

Basta


--

Dave Peterson


All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com