Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
pam pam is offline
external usenet poster
 
Posts: 11
Default What's Wrong?

I'm trying to color the background of a row if a certain
set of conditions exists.

I don't know what's wrong with this:

For i = rng.Row To 1 Step -1

If Cells(i, 9).Value = Cells(i - 1, 10).Value _
And Cells(i, 10).Value = Cells(i - 1, 9).Value _
And Cells(i, 1).Value = Cells(i - 1, 1).Value _
And Cells(i, 2).Value = Cells(i - 1, 2).Value _
Then Cells(i, 1).EntireRow.Interior.ColorIndex = 35
end if
Next

I've tried taking out the "end if", including just "end",
but nothing works??? I get a 1004 error.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default What's Wrong?

Hi
just remove the 'End if' statement

--
Regards
Frank Kabel
Frankfurt, Germany

"Pam" schrieb im Newsbeitrag
...
I'm trying to color the background of a row if a certain
set of conditions exists.

I don't know what's wrong with this:

For i = rng.Row To 1 Step -1

If Cells(i, 9).Value = Cells(i - 1, 10).Value _
And Cells(i, 10).Value = Cells(i - 1, 9).Value _
And Cells(i, 1).Value = Cells(i - 1, 1).Value _
And Cells(i, 2).Value = Cells(i - 1, 2).Value _
Then Cells(i, 1).EntireRow.Interior.ColorIndex = 35
end if
Next

I've tried taking out the "end if", including just "end",
but nothing works??? I get a 1004 error.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default What's Wrong?

For i = rng.Row To 1 Step -1

If Cells(i, 9).Value = Cells(i - 1, 10).Value _
And Cells(i, 10).Value = Cells(i - 1, 9).Value _
And Cells(i, 1).Value = Cells(i - 1, 1).Value _
And Cells(i, 2).Value = Cells(i - 1, 2).Value _
Then
Cells(i, 1).EntireRow.Interior.ColorIndex = 35
end if
Next

or

For i = rng.Row To 1 Step -1

If Cells(i, 9).Value = Cells(i - 1, 10).Value _
And Cells(i, 10).Value = Cells(i - 1, 9).Value _
And Cells(i, 1).Value = Cells(i - 1, 1).Value _
And Cells(i, 2).Value = Cells(i - 1, 2).Value _
Then Cells(i, 1).EntireRow.Interior.ColorIndex = 35

Next

Both compile fine for me. However, I assume this is part of a larger
procedure, so it could be affected by code I can not see.

--
Regards,
Tom Ogilvy

"Pam" wrote in message
...
I'm trying to color the background of a row if a certain
set of conditions exists.

I don't know what's wrong with this:

For i = rng.Row To 1 Step -1

If Cells(i, 9).Value = Cells(i - 1, 10).Value _
And Cells(i, 10).Value = Cells(i - 1, 9).Value _
And Cells(i, 1).Value = Cells(i - 1, 1).Value _
And Cells(i, 2).Value = Cells(i - 1, 2).Value _
Then Cells(i, 1).EntireRow.Interior.ColorIndex = 35
end if
Next

I've tried taking out the "end if", including just "end",
but nothing works??? I get a 1004 error.



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
What is wrong with my UDF jlclyde Excel Discussion (Misc queries) 4 October 24th 08 03:06 PM
What am I doing wrong? tjbo Charts and Charting in Excel 3 October 10th 08 02:08 PM
Insert Calculated Field (wrong Qty*Price = wrong Amount) Edmund Excel Discussion (Misc queries) 8 October 4th 07 12:13 PM
What am I doing wrong? Jeff New Users to Excel 4 March 6th 05 03:05 AM
What am I doing wrong? Jeff Excel Discussion (Misc queries) 6 March 6th 05 03:01 AM


All times are GMT +1. The time now is 09:03 PM.

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"