Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
dave, i did have it working with another approach before that. here is the code
i used. they both seem to work fine. let me know if you see any issues. thanks frow = ws.Range("A1").End(xlDown).Row ws.Range("I" & frow).Select Set rng = ws.Range(Cells(ActiveCell.Row + 1, ActiveCell.Column), Cells(Rows.Count, ActiveCell.Column)) Do t1 = ActiveCell.Value rng.SpecialCells(xlCellTypeVisible).Cells(1).Selec t t2 = rng.SpecialCells(xlCellTypeVisible).Cells(1).Value If t1 < t2 Then With ActiveCell.Offset(0, -7).Resize(1, 23).Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlMedium .ColorIndex = 5 End With Else Set rng = ws.Range(Cells(ActiveCell.Row + 1, ActiveCell.Column), Cells(Rows.Count, ActiveCell.Column)) End If Loop While ActiveCell.Row < lastrow -- Gary "Dave Peterson" wrote in message ... One way is to just look above, but check to see if that cell above is visible. If it's not, just keep looking. Another way is to look at each area in the visible cells (in that column). dim rngV as range dim myArea as range dim myCell as range dim VCellAbove as range dim FoundIt as boolean dim aCtr as long with activesheet.autofilter.range set rngv = .columns(1).resize(.rows.count-1,1) _ .offset(1,0).cells.specialcells(xlcelltypevisible) end with set mycell = .range("a99") 'who knows what cell you're looking for foundit = false for aCtr = 1 to rngv.areas.count if intersect(rngv.areas(ictr), mycell) then foundit = true exit for end if next actr if foundit = false then msgbox "not in the correct range" exit sub end if set vcellabove = nothing if mycell.address = rngv.areas(actr).cells(1).address then if actr = 1 then 'nothing above this cell in the top area else 'last cell in previous area with rngv.areas(actr-1) set vcellabove = .cells(.cells.count) end with end if else 'just the cell above set vcellabove = mycell.offset(0,-1) end if if vcellabove is nothing then msgbox "Nothing above" else msgbox vcellabove.address end if ========= Watch for typos--it's untested and uncompiled. Gary Keramidas wrote: is there a way to compare a cells value to an adjacent cell, above the current cell, so i can compare the 2? can't use offset and .SpecialCells(xlCellTypeVisible) isn't cooperating with me. just don't know how to get the cell value of the cell above the current cell. thanks -- Gary -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Autofilter Question | Excel Discussion (Misc queries) | |||
AutoFilter Question | Excel Discussion (Misc queries) | |||
Autofilter question | Excel Programming | |||
AutoFilter Question | Excel Discussion (Misc queries) | |||
AUTOFILTER QUESTION | Excel Programming |