![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
Who can give me a shorter marco instructions for the following line:
If Cells(x, 4) > Cells(x, 5) And Cells(x, 5) > Cells(x, 6) And Cells(x, 6) > Cells(x, 7) And Cells(x, 7) > Cells(x, Range(Cells(x, 4), Cells(x, 256).End(xlToLeft)).Interior.ColorIndex = 33 (P.S. X = rownumber) Many thanks |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
How about the following...
Code:
Sub test()
Dim Rng1 As Range, Rng2 As Range
Dim x As Long, y As Integer
x = 1
y = 7
Set Rng1 = Cells(x, 4).Resize(, y)
Set Rng2 = Rng1.Offset(0, 1)
If Evaluate("=SUM(IF(" & Rng2.Address & ">" & Rng1.Address & ",1))") = y Then
Range(Cells(x, 4), Cells(x, 256).End(xlToLeft)).Interior.ColorIndex = 33
End If
End Sub
Jay |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|