Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default It Then Else Question

What is wrong with the following code? I get a compile error 'Else without
IF"

If LinkBudget.Range("E143") < -14 Then
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 6750105
Else
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 255
End If

Thanks,

W Wolfe


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default It Then Else Question

Hi,

It's actually the WITH statement giving the error, there's no END WITH. Try
this

If LinkBudget.Range("E143") < -14 Then
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 6750105
End With
Else
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 255
End With
End If

Mike

"William Wolfe" wrote:

What is wrong with the following code? I get a compile error 'Else without
IF"

If LinkBudget.Range("E143") < -14 Then
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 6750105
Else
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 255
End If

Thanks,

W Wolfe



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default It Then Else Question

You are missing the two End With statements that are needed to close the two
With statements that you created (although you can easily eliminate them as
you only reference back to them one time each). As to why the "Else with If"
message... VB looks to close all statements that require a closing pair
(If..End If, Do..Loop, Select Case..End Select, etc.)... if it is missing
one or more, it just generates a compile error message of what it **thinks**
it could be, but it doesn't analyze the actual structure to see what is
actually missing; so you shouldn't focus on the wording of the message as
much as on the fact that the message was issued, then start looking for a
missing closing statement of some kind.

--
Rick (MVP - Excel)


"William Wolfe" wrote in message
...
What is wrong with the following code? I get a compile error 'Else
without IF"

If LinkBudget.Range("E143") < -14 Then
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 6750105
Else
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 255
End If

Thanks,

W Wolfe


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default It Then Else Question

Thanks to all.

W. Wolfe

"Mike H" wrote in message
...
Hi,

It's actually the WITH statement giving the error, there's no END WITH.
Try
this

If LinkBudget.Range("E143") < -14 Then
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 6750105
End With
Else
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 255
End With
End If

Mike

"William Wolfe" wrote:

What is wrong with the following code? I get a compile error 'Else
without
IF"

If LinkBudget.Range("E143") < -14 Then
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 6750105
Else
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 255
End If

Thanks,

W Wolfe





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default It Then Else Question

Detail_Report.Cells(61, Column).Select

Hi. Instead of selecting, would something like this help?

Detail_Report.Cells(61, Column).Interior.Color = _
IIf(LinkBudget.Range("E143") < -14, 6750105, 255)

= = = = = = = = = =
HTH :)
Dana DeLouis



On 10/6/09 12:27 PM, William Wolfe wrote:
Thanks to all.

W. Wolfe

"Mike wrote in message
...
Hi,

It's actually the WITH statement giving the error, there's no END WITH.
Try
this

If LinkBudget.Range("E143")< -14 Then
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 6750105
End With
Else
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 255
End With
End If

Mike

"William Wolfe" wrote:

What is wrong with the following code? I get a compile error 'Else
without
IF"

If LinkBudget.Range("E143")< -14 Then
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 6750105
Else
Detail_Report.Cells(61, Column).Select
With Selection.Interior
.Color = 255
End If

Thanks,

W Wolfe






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
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good davegb Excel Programming 1 May 6th 05 06:35 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 27th 05 07:46 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 22nd 05 03:30 PM


All times are GMT +1. The time now is 12:59 AM.

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

About Us

"It's about Microsoft Excel"