Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default find first cell not equal to current cell


What is the best way to find the next cell down in a column that does
not equal the current cell? Do I have to use a while loop?

while cells(i,2).value = oldCellValue
i = i+1


--
TommySzalapski
------------------------------------------------------------------------
TommySzalapski's Profile: http://www.excelforum.com/member.php...o&userid=25561
View this thread: http://www.excelforum.com/showthread...hreadid=392944

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default find first cell not equal to current cell

Yes, sounds good.
---------------------------------------------------------------
Dim i As Long

On Error GoTo exit_Sub

Do While True
i = i + 1
If ActiveCell.Offset(i, 0).Value < ActiveCell.Value Then
MsgBox "Next Value Cell: " & ActiveCell.Offset(i, 0).Address
Exit Do
End If
Loop

exit_Sub:
---------------------------------------------------------------


HTH,
--
Gary Brown

If this post was helpful, please click the ''''Yes'''' button next to
''''Was this Post Helpfull to you?".


"TommySzalapski" wrote:


What is the best way to find the next cell down in a column that does
not equal the current cell? Do I have to use a while loop?

while cells(i,2).value = oldCellValue
i = i+1


--
TommySzalapski
------------------------------------------------------------------------
TommySzalapski's Profile:
http://www.excelforum.com/member.php...o&userid=25561
View this thread: http://www.excelforum.com/showthread...hreadid=392944


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default find first cell not equal to current cell

what about ColumnDifferences method:

Function NextValueCell(Cell As Range) As Range
Const ROWSIZE = 1000 'MAX:16384
Dim c As Range, r As Range
Dim i As Long, j As Long, n As Long
On Error GoTo ErrorHandler
Set c = Cell.Cells(1)
'If c.Worksheet.ProtectContents And _
' Not c.Worksheet.ProtectionMode Then Exit Function
n = c.Worksheet.Rows.Count - c.Row + 1
For i = 1 To n Step ROWSIZE
If i + ROWSIZE < n Then j = ROWSIZE + 1 Else j = n - i + 1
On Error Resume Next
Set r = c(i, 1).Resize(j).ColumnDifferences(c(i, 1))(1)
On Error GoTo ErrorHandler
If Not r Is Nothing Then Exit For
Next
Set NextValueCell = r
Exit Function
ErrorHandler:
Exit Function
End Function

Sub Test()
On Error Resume Next
NextValueCell(ActiveCell).Activate
End Sub

--
HTH,

okaizawa


TommySzalapski wrote:
What is the best way to find the next cell down in a column that does
not equal the current cell? Do I have to use a while loop?

while cells(i,2).value = oldCellValue
i = i+1


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
How to find different numbers that equal a number in another cell? kashifayman Excel Discussion (Misc queries) 1 February 22nd 10 06:31 PM
Find first cell in a row not equal to John Excel Worksheet Functions 3 December 4th 07 08:13 PM
How to:Find the row of the first cell not equal to several values Vasil Ivanov Excel Worksheet Functions 3 October 2nd 06 02:11 PM
how do you find a cell equal to a cell from another list Graham56 Excel Discussion (Misc queries) 2 September 19th 05 11:09 AM
Find cell and determine value in current row Kathy - Lovullo Excel Programming 1 December 28th 04 02:13 PM


All times are GMT +1. The time now is 09:49 AM.

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"