Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default For..Next error 'End if without block if'

Hi - I am a little stuck here. I am sure it is something easy.

Sub testing()

Dim irows As Integer
Dim iloop
Dim iloop2
irows = ActiveSheet.UsedRange.Rows.Count

For iloop = irows To 2 Step -1
If Cells(iloop, 8) < "" Then _
For iloop2 = irows To 2 Step -1
If Cells(iloop2, 11) = Cells(iloop, 8) Then _
Cells(iloop2, 5).Value = Cells(iloop, 5).Value
Cells(iloop, 1).EntireRow.Delete
Next iloop2
Next iloop
End Sub


I am getting the 'End if without Block if' error. Help please.

Thank you,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default For..Next error 'End if without block if'

On Jan 10, 3:51*pm, Mike R. wrote:
Hi - I am a little stuck here. *I am sure it is something easy. *

Sub testing()

* * Dim irows As Integer
* * Dim iloop
* * Dim iloop2
* * irows = ActiveSheet.UsedRange.Rows.Count

* * For iloop = irows To 2 Step -1
* * * * If Cells(iloop, 8) < "" Then _
* * * * * * For iloop2 = irows To 2 Step -1
* * * * * * * * If Cells(iloop2, 11) = Cells(iloop, 8) Then _
* * * * * * * * * * Cells(iloop2, 5).Value = Cells(iloop, 5).Value
* * * * * * * * * * Cells(iloop, 1).EntireRow.Delete
* * * * * * Next iloop2
* * Next iloop
End Sub

I am getting the 'End if without Block if' error. *Help please. *

Thank you,


you forget the end if between next iloop2 and next iloop

cheers carlo
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default For..Next error 'End if without block if'

On Jan 10, 3:51*pm, Mike R. wrote:
Hi - I am a little stuck here. *I am sure it is something easy. *

Sub testing()

* * Dim irows As Integer
* * Dim iloop
* * Dim iloop2
* * irows = ActiveSheet.UsedRange.Rows.Count

* * For iloop = irows To 2 Step -1
* * * * If Cells(iloop, 8) < "" Then _
* * * * * * For iloop2 = irows To 2 Step -1
* * * * * * * * If Cells(iloop2, 11) = Cells(iloop, 8) Then _
* * * * * * * * * * Cells(iloop2, 5).Value = Cells(iloop, 5).Value
* * * * * * * * * * Cells(iloop, 1).EntireRow.Delete
* * * * * * Next iloop2
* * Next iloop
End Sub

I am getting the 'End if without Block if' error. *Help please. *

Thank you,


And also before next iloop2

in VBA If needs to be ended with end if as long as it is one more then
one line.

cheers
Carlo
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default For..Next error 'End if without block if'

Thank you Carlo. Can't believe I missed that. I have updated it, but am
still getting the same error. Here is my new code:
Sub testing()

Dim irows As Integer
Dim iloop
Dim iloop2
irows = ActiveSheet.UsedRange.Rows.Count

For iloop = irows To 2 Step -1
If Cells(iloop, 8) < "" Then _
For iloop2 = irows To 2 Step -1
If Cells(iloop2, 11) = Cells(iloop, 8) Then _
Cells(iloop2, 5).Value = Cells(iloop, 5).Value
Cells(iloop, 1).EntireRow.Delete
End If
Next iloop2
End If
Next iloop
End Sub

Does it look right?
Thanks,
Mike

"carlo" wrote:

On Jan 10, 3:51 pm, Mike R. wrote:
Hi - I am a little stuck here. I am sure it is something easy.

Sub testing()

Dim irows As Integer
Dim iloop
Dim iloop2
irows = ActiveSheet.UsedRange.Rows.Count

For iloop = irows To 2 Step -1
If Cells(iloop, 8) < "" Then _
For iloop2 = irows To 2 Step -1
If Cells(iloop2, 11) = Cells(iloop, 8) Then _
Cells(iloop2, 5).Value = Cells(iloop, 5).Value
Cells(iloop, 1).EntireRow.Delete
Next iloop2
Next iloop
End Sub

I am getting the 'End if without Block if' error. Help please.

Thank you,


And also before next iloop2

in VBA If needs to be ended with end if as long as it is one more then
one line.

cheers
Carlo

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 367
Default For..Next error 'End if without block if'

On Jan 10, 4:29*pm, Mike R. wrote:
Thank you Carlo. *Can't believe I missed that. *I have updated it, but am
still getting the same error. *Here is my new code:
Sub testing()

* * Dim irows As Integer
* * Dim iloop
* * Dim iloop2
* * irows = ActiveSheet.UsedRange.Rows.Count

* * For iloop = irows To 2 Step -1
* * * * If Cells(iloop, 8) < "" Then _
* * * * * * For iloop2 = irows To 2 Step -1
* * * * * * * * If Cells(iloop2, 11) = Cells(iloop, 8) Then _
* * * * * * * * * * Cells(iloop2, 5).Value = Cells(iloop, 5).Value
* * * * * * * * * * Cells(iloop, 1).EntireRow.Delete
* * * * * * * * *End If
* * * * * * Next iloop2
* * * * End If
* * Next iloop
End Sub

Does it look right?
Thanks,
Mike



"carlo" wrote:
On Jan 10, 3:51 pm, Mike R. wrote:
Hi - I am a little stuck here. *I am sure it is something easy. *


Sub testing()


* * Dim irows As Integer
* * Dim iloop
* * Dim iloop2
* * irows = ActiveSheet.UsedRange.Rows.Count


* * For iloop = irows To 2 Step -1
* * * * If Cells(iloop, 8) < "" Then _
* * * * * * For iloop2 = irows To 2 Step -1
* * * * * * * * If Cells(iloop2, 11) = Cells(iloop, 8) Then _
* * * * * * * * * * Cells(iloop2, 5).Value = Cells(iloop, 5).Value
* * * * * * * * * * Cells(iloop, 1).EntireRow.Delete
* * * * * * Next iloop2
* * Next iloop
End Sub


I am getting the 'End if without Block if' error. *Help please. *


Thank you,


And also before next iloop2


in VBA If needs to be ended with end if as long as it is one more then
one line.


cheers
Carlo- Hide quoted text -


- Show quoted text -


Hei Mike

the _ mess your code up, this should work:

Sub testing()

Dim irows As Integer
Dim iloop
Dim iloop2
irows = ActiveSheet.UsedRange.Rows.Count


For iloop = irows To 2 Step -1
If Cells(iloop, 8) < "" Then
For iloop2 = irows To 2 Step -1
If Cells(iloop2, 11) = Cells(iloop, 8) Then
Cells(iloop2, 5).Value = Cells(iloop, 5).Value
Cells(iloop, 1).EntireRow.Delete
End If
Next iloop2
End If
Next iloop
End Sub


cheers

Carlo


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default For..Next error 'End if without block if'

Try removing the underscores after Then. In VBA underscores signify that the
line continues, but the If ... Then ... End If structure requires Then to be
the last term on the first line.

Best,
Bo

"Mike R." wrote:

Thank you Carlo. Can't believe I missed that. I have updated it, but am
still getting the same error. Here is my new code:
Sub testing()

Dim irows As Integer
Dim iloop
Dim iloop2
irows = ActiveSheet.UsedRange.Rows.Count

For iloop = irows To 2 Step -1
If Cells(iloop, 8) < "" Then _
For iloop2 = irows To 2 Step -1
If Cells(iloop2, 11) = Cells(iloop, 8) Then _
Cells(iloop2, 5).Value = Cells(iloop, 5).Value
Cells(iloop, 1).EntireRow.Delete
End If
Next iloop2
End If
Next iloop
End Sub

Does it look right?
Thanks,
Mike

"carlo" wrote:

On Jan 10, 3:51 pm, Mike R. wrote:
Hi - I am a little stuck here. I am sure it is something easy.

Sub testing()

Dim irows As Integer
Dim iloop
Dim iloop2
irows = ActiveSheet.UsedRange.Rows.Count

For iloop = irows To 2 Step -1
If Cells(iloop, 8) < "" Then _
For iloop2 = irows To 2 Step -1
If Cells(iloop2, 11) = Cells(iloop, 8) Then _
Cells(iloop2, 5).Value = Cells(iloop, 5).Value
Cells(iloop, 1).EntireRow.Delete
Next iloop2
Next iloop
End Sub

I am getting the 'End if without Block if' error. Help please.

Thank you,


And also before next iloop2

in VBA If needs to be ended with end if as long as it is one more then
one line.

cheers
Carlo

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default For..Next error 'End if without block if'

PERFECT. Thanks!!

"Mike R." wrote:

Hi - I am a little stuck here. I am sure it is something easy.

Sub testing()

Dim irows As Integer
Dim iloop
Dim iloop2
irows = ActiveSheet.UsedRange.Rows.Count

For iloop = irows To 2 Step -1
If Cells(iloop, 8) < "" Then _
For iloop2 = irows To 2 Step -1
If Cells(iloop2, 11) = Cells(iloop, 8) Then _
Cells(iloop2, 5).Value = Cells(iloop, 5).Value
Cells(iloop, 1).EntireRow.Delete
Next iloop2
Next iloop
End Sub


I am getting the 'End if without Block if' error. Help please.

Thank you,

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
Error: Block If without End If [email protected] Excel Programming 2 October 30th 07 08:17 PM
end if without block if error stewart Excel Programming 4 September 17th 07 12:01 AM
End If without Block If Error Help Bull Excel Programming 6 April 30th 07 08:24 PM
VBA error - End If without Block If Jane Excel Worksheet Functions 2 December 6th 05 06:00 PM
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 06:41 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"