View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
INTP56 INTP56 is offline
external usenet poster
 
Posts: 66
Default Find first value != to something in Excel 2003

Is it possible to find the first value in a range that is not equal to a
value? I mean, aside from iterating through all the cells.

I have a data set where there might be thousands of lines with a column
value that rarely changes.

What I would like, is to get the first value in a column, then search that
column for the first occurance of a different value.

Is there a way to do it with the Find method of the Range object?

For Example:

Dim rngColumnHeader as Range,rngSearchRange as Range
Dim lngPowerSetting as Long, rngDifferent as Range

'Look for my column header
Set rngColumnHeader = ActiveSheet.Find(What:="Power Setting",
LookIn:=xlValues, LookAt:=xlWhole)

If Not rngColumnHeader is Nothing Then
'If I find it, get the range to search
Set rngSearchRange =
ActiveSheet.Range(rngColumnHeader.Offset(1,0),rngC olumnHeader.End(xlDown))

lngPowerSetting = rngSearchRange.Cells(1).Value

Set rngDifferent = rngSearchRange.Find(What:= ?,LookIn:=xlValues,
LookAt:=xlWhole)

'What do I put in for the question mark to signify a value other than
lngPowerSetting? If I do get a hit, I need to grab other values in the same
row.

Thanks,

Bob

P.S. My values are not sorted, and can go up or down. The test data set I
have to work with has 80 columns with 9000 rows and about 20 columns I need
to do this to. The Power Setting column in my test data set has about 3000
rows of 20, 500 rows of 50, 3000 rows of 20, and the rest 10.