Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default end if without block if

This is a very eay macro and yet Excel complains about an "end if
without block if". Why???

Sub check()

Count = 0
For i = 1 To 9
For j = 1 To 9
If Cells(i + 3, j + 3) < Cells(i + 26, j + 26) Then Do
Cells(i + 3, j + 3).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Count = Count + 1
End If
Next j
Next i


If Count 0 Then MsgBox (Count & "are still wrong")
If Count = 0 Then MsgBox ("You have solved it")
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default end if without block if

I'm not sure what the purpose of "Do" is in your code. Try it without. And
I prefer to space out the block if's and with's to make for easier reading
and debugging.

Sub check()

Count = 0
For i = 1 To 9
For j = 1 To 9
If Cells(i + 3, j + 3) < Cells(i + 26, j + 26) _
Then
Cells(i + 3, j + 3).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Count = Count + 1
Else
End If
Next j
Next i


If Count 0 Then MsgBox (Count & "are still wrong")
If Count = 0 Then MsgBox ("You have solved it")
End Sub


HTH,
Paul



"Dirk Nachbar" wrote in message
oups.com...
This is a very eay macro and yet Excel complains about an "end if
without block if". Why???

Sub check()

Count = 0
For i = 1 To 9
For j = 1 To 9
If Cells(i + 3, j + 3) < Cells(i + 26, j + 26) Then Do
Cells(i + 3, j + 3).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Count = Count + 1
End If
Next j
Next i


If Count 0 Then MsgBox (Count & "are still wrong")
If Count = 0 Then MsgBox ("You have solved it")
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default end if without block if

yes it was the DO, thanks

Dirk

On 20 Jul, 17:08, "PCLIVE" wrote:
I'm not sure what the purpose of "Do" is in your code. Try it without. And
I prefer to space out the block if's and with's to make for easier reading
and debugging.

Sub check()

Count = 0
For i = 1 To 9
For j = 1 To 9
If Cells(i + 3, j + 3) < Cells(i + 26, j + 26) _
Then
Cells(i + 3, j + 3).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Count = Count + 1
Else
End If
Next j
Next i

If Count 0 Then MsgBox (Count & "are still wrong")
If Count = 0 Then MsgBox ("You have solved it")
End Sub

HTH,
Paul

"Dirk Nachbar" wrote in message

oups.com...



This is a very eay macro and yet Excel complains about an "end if
without block if". Why???


Sub check()


Count = 0
For i = 1 To 9
For j = 1 To 9
If Cells(i + 3, j + 3) < Cells(i + 26, j + 26) Then Do
Cells(i + 3, j + 3).Select
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Count = Count + 1
End If
Next j
Next i


If Count 0 Then MsgBox (Count & "are still wrong")
If Count = 0 Then MsgBox ("You have solved it")
End Sub- Hide quoted text -


- Show quoted text -



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
End if without Block If Carrie_Loos via OfficeKB.com Excel Worksheet Functions 7 May 14th 08 06:47 PM
Average per block PP Excel Worksheet Functions 4 November 30th 06 07:22 PM
if/then block within another if/then block needs a loop Janis Excel Programming 1 September 8th 06 10:01 PM
Block If DA@PD[_2_] Excel Programming 16 December 17th 05 01:57 AM
Error - End If Without Block Gauthier[_2_] Excel Programming 6 September 26th 04 05:14 AM


All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"