Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default another autofilter question

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



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
Autofilter Question veryeavy Excel Discussion (Misc queries) 0 April 24th 08 02:00 AM
AutoFilter Question Ram Excel Discussion (Misc queries) 6 November 27th 06 04:05 PM
Autofilter question MikeG22 Excel Programming 5 October 10th 06 08:45 PM
AutoFilter Question AccessHelp Excel Discussion (Misc queries) 2 September 29th 06 09:25 PM
AUTOFILTER QUESTION Dan Excel Programming 1 March 2nd 05 04:36 PM


All times are GMT +1. The time now is 12:56 PM.

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

About Us

"It's about Microsoft Excel"