Macro

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
Why I receive an error at the line:
".Interiorcolor.Index = 2" ?
Can somebody help me?
Many thanks.
While Cells(x, 1).Text <> ""
If Cells(x, 3).Value >= Cells(x, 4).Value Then
With Cells(x, 3)
.Interior.ColorIndex = 6
End With
Else
With Cells(x, 3) And Cells(x, 4) And Cells(x, 5) And Cells(x, 6) And Cells(x, 7) And Cells(x, :cool: And Cells(x, 9) And Cells(x, 10)
.Interior.ColorIndex = 2
End With
End If
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi
Add a continuation _
after this line:

And Cells(x, And Cells(x, 9) And Cells(x, 10)

Should be:

And Cells(x, And Cells(x, 9) And Cells(x, 10) _

Good Day!
Tom
 
Upvote 0
On 2002-04-03 02:18, TsTom wrote:
Hi
Add a continuation _
after this line:

And Cells(x, And Cells(x, 9) And Cells(x, 10)

Should be:

And Cells(x, And Cells(x, 9) And Cells(x, 10) _

Good Day!
Tom
Tom,

I receive still a syntaxis-error at that line afther add the continuation _
Have you any idea about this?
Thanks.
 
Upvote 0
Hi

You cannot use the With Statement on more than one Object as you have. Change it to:

For i = 3 To 10
Cells(x, i).Interior.ColorIndex = 6
Next i


OR

Range(Cells(x, 3), Cells(x, 10)).Interior.ColorIndex = 6
_________________
Kind Regards
Dave Hawley
OzGrid Business Applications
Microsoft Excel/VBA Training
OzGrid.BusApp.170x45.gif

This message was edited by Dave Hawley on 2002-04-03 03:19
 
Upvote 0
On 2002-04-03 03:16, Dave Hawley wrote:
Hi

You cannot use the With Statement on more than one Object as you have. Change it to:

For i = 3 To 10
Cells(x, i).Interior.ColorIndex = 6
Next i


OR

Range(Cells(x, 3), Cells(x, 10)).Interior.ColorIndex = 6
_________________
Kind Regards
Dave Hawley
OzGrid Business Applications
Microsoft Excel/VBA Training
OzGrid.BusApp.170x45.gif

This message was edited by Dave Hawley on 2002-04-03 03:19
Thanks,your last suggestion works fine.
Can you tell me,is it possible that:Range(Cells(x, 3), Cells(x,10)).Interior.ColorIndex = 6

Cells(X,10) could be the last empty column otherwise I must change each time the number 10 to 11 or 12 or 13 .....
Many thanks.
 
Upvote 0
Try this, I think it's what you want.

Code:
Range(Cells(x, 3), Cells(x, 256).End(xlToLeft)).Interior.ColorIndex = 6
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,165
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top