LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default can this formula be quickened or coded?


I fixed the problem. the reason the code hung was if you were on row 10 and
the data was 8 in column C the macro would find 8 also in row 20 and 30 but
column L was empty in both cases. the code would get hung in a loop finding
8 in row 20, then 30, then 20, then 30 and never getting out of the code.
The problem with find and find next is it wraps and when it gets to the last
row goes back to the 1st row in the search field.


The code right now wraps that if it doesn't find the number at a row higher
than then current row it goes back to row 3 and searches until it gets to the
current row. So the result is it will put the data from column L on a lower
row instead of a higher row If you don't want it to wrap and put and leave a
blank if it doesn't find the number in a higher row then make this change

from:
Range("S" & RowCount) = Num
to:
if c.Row RowCount then
Range("S" & RowCount) = Num
end if

Sub GetNext()

LastRow = Range("C" & Rows.Count).End(xlUp).Row
For RowCount = 3 To (LastRow - 1)
Data = Range("C" & RowCount)
With Range("C3:C" & LastRow)
Set c = .Find(what:=Data, after:=Range("C" & RowCount), _
LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
Num = Range("L" & c.Row)
Do While Num = "" And _
Not c Is Nothing And _
c.Row RowCount

Set c = .FindNext(after:=c)
Num = Range("L" & c.Row)
Loop

Range("S" & RowCount) = Num
End If
End With
Next RowCount

End Sub


"colwyn" wrote:


Joel Guest - thanks. Still not working. It works on the first range then
freezes. On 'debug' it highlights the line "Num = Range("L" & c.Row)"

???
Can it be fixed?
Big thanks.
Colwyn.


--
colwyn
------------------------------------------------------------------------
colwyn's Profile: http://www.thecodecage.com/forumz/member.php?userid=34
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=47019


 
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
F2 - NO color-coded precedents??? TimK Excel Discussion (Misc queries) 2 June 30th 09 05:35 PM
Hard coded formula fix, VBA for column ordering undrline via OfficeKB.com Excel Worksheet Functions 2 September 14th 08 08:53 AM
Coded Information brenda Excel Discussion (Misc queries) 1 July 9th 07 11:26 PM
hit F2, want the color coded formula to appear in formula bar not Tiff L Excel Worksheet Functions 1 April 11th 06 02:30 PM
Limit of color-coded cell references editing a formula. u2sparky Excel Discussion (Misc queries) 1 September 9th 05 07:06 PM


All times are GMT +1. The time now is 08:33 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"