Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 46
Default Compile error

When I run the following macro:

--------------------------------------------------------------------------

For r = 2 To 50
For c = 4 To 50



If Cells(r, 4) = "" Then Cells(r, 2) = 0
End If

If Cells(r, c) 0 And Cells(r, c + 1) = "" Then Cells(r, 2) = c - 3

End If
Next
Next

------------------------------------------------------------------

I get the following message:

------------------------------------------------------------------------

Compile error

End if without block if


OK Help
-----------------------------------------------------

How do I correct the macro?

Would appreciate any help


EJE
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Compile error

Hi Eje,

For r = 2 To 50
For c = 4 To 50

If Cells(r, 4) = "" Then Cells(r, 2) = 0
If Cells(r, c) 0 And Cells(r, c + 1) = "" Then Cells(r, 2) = c - 3
Next
Next

or

For r = 2 To 50
For c = 4 To 50

If Cells(r, 4) = "" Then
Cells(r, 2) = 0
End If

If Cells(r, c) 0 And Cells(r, c + 1) = "" Then
Cells(r, 2) = c - 3
End If
Next
Next

Regards,
Ivan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 249
Default Compile error

Remove "End If" in both places.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Ed" wrote:
| When I run the following macro:
|
| --------------------------------------------------------------------------
|
| For r = 2 To 50
| For c = 4 To 50
|
|
|
| If Cells(r, 4) = "" Then Cells(r, 2) = 0
| End If
|
| If Cells(r, c) 0 And Cells(r, c + 1) = "" Then Cells(r, 2) = c - 3
|
| End If
| Next
| Next
|
| ------------------------------------------------------------------
|
| I get the following message:
|
| ------------------------------------------------------------------------
|
| Compile error
|
| End if without block if
|
|
| OK Help
| -----------------------------------------------------
|
| How do I correct the macro?
|
| Would appreciate any help
|
|
| EJE


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Compile error

Hi Ed,

If Cells(r, 4) = "" Then Cells(r, 2) = 0
End If



Try

If Cells(r, 4) = "" Then Cells(r, 2) = 0 End If

or

If Cells(r, 4) = "" Then
Cells(r, 2) = 0
End If


---
Regards,
Norman



"Ed" wrote in message
...
When I run the following macro:

--------------------------------------------------------------------------

For r = 2 To 50
For c = 4 To 50



If Cells(r, 4) = "" Then Cells(r, 2) = 0
End If

If Cells(r, c) 0 And Cells(r, c + 1) = "" Then Cells(r, 2) = c - 3

End If
Next
Next

------------------------------------------------------------------

I get the following message:

------------------------------------------------------------------------

Compile error

End if without block if


OK Help
-----------------------------------------------------

How do I correct the macro?

Would appreciate any help


EJE



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Compile error


You can remove the "End If" statements since you put the "Then"
statement on the same line as the "If". Like this:
For r = 2 To 50
For c = 4 To 50
If Cells(r, 4) = "" Then Cells(r, 2) = 0
If Cells(r, c) 0 And Cells(r, c + 1) = "" Then Cells(r, 2) = c - 3
Next
Next

If you want to use the "end if" it'd look like this:
If Cells(r, 4) = "" Then
Cells(r, 2) = 0
End If

Ed Wrote:
When I run the following macro:

--------------------------------------------------------------------------

For r = 2 To 50
For c = 4 To 50



If Cells(r, 4) = "" Then Cells(r, 2) = 0
End If

If Cells(r, c) 0 And Cells(r, c + 1) = "" Then Cells(r, 2) = c - 3

End If
Next
Next

------------------------------------------------------------------

I get the following message:

------------------------------------------------------------------------

Compile error

End if without block if


OK Help
-----------------------------------------------------

How do I correct the macro?

Would appreciate any help


EJE



--
Ikaabod
------------------------------------------------------------------------
Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371
View this thread: http://www.excelforum.com/showthread...hreadid=544285



  #6   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 46
Default Compile error


Mant thanks to all who helped


Ed


On Mon, 22 May 2006 08:22:23 -0500, Ed wrote:

When I run the following macro:

--------------------------------------------------------------------------

For r = 2 To 50
For c = 4 To 50



If Cells(r, 4) = "" Then Cells(r, 2) = 0
End If

If Cells(r, c) 0 And Cells(r, c + 1) = "" Then Cells(r, 2) = c - 3

End If
Next
Next

------------------------------------------------------------------

I get the following message:

------------------------------------------------------------------------

Compile error

End if without block if


OK Help
-----------------------------------------------------

How do I correct the macro?

Would appreciate any help


EJE

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
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
error message: compile error, argument not optional Pierre via OfficeKB.com Excel Programming 3 September 5th 05 03:45 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


All times are GMT +1. The time now is 02:07 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"