View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Simon Lloyd[_1101_] Simon Lloyd[_1101_] is offline
external usenet poster
 
Posts: 1
Default Looping help needed


Hi Makelei, my apologies for not having time to look at your attachment,
glad your sorted!

Thanks very much for posting back your solution as this will help many
others with the same or similar problem.

Makelei;317144 Wrote:
Hi,
I was able to solve this problem on my own - thanks for your time.
Here is how I solved it:

Code:
--------------------

Sub OrgsWithNames()
Dim LRw, i, Org, OrgF
Application.ScreenUpdating = False

Columns("I:M").ClearContents
LRw = Cells(Rows.Count, "E").End(xlUp).Row

For i = 8 To LRw
If (Left(Range("A" & i).Value, 2) = 50 And Len(Range("A" & i).Value)
7) Or (Left(Range("B" & i).Value, 2) = 50 And Len(Range("B" & i).Value)

7) Then

Range("A" & i + 1).Select
Org = Range("A" & i).Value & Range("B" & i).Value

OrgF = Range("A" & i & ":B20000").Find(What:=Org,
After:=ActiveCell _
, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False).Row

If OrgF i Then
Range("K" & i & ":K" & OrgF + 3).Value = Org
Range("L" & i).Value = OrgF
Else
End If

Else

End If

Next i
Application.ScreenUpdating = True

End Sub


--------------------

Makelei



"MakeLei" wrote:


Hi,
Here a sample list. List is over 20 000 rows as a total. Data is in
file as it is as I get it. As you run the macro it will add

organization
info to column K. I have commented rows that are problematic for me
(rows 86 - 88).

Thanks for helping me out. I know this is not very hard, but I just
don't get it...

Makelei



+-------------------------------------------------------------------+
|Filename: Example.xls |
|Download:

http://www.thecodecage.com/forumz/attachment.php?attachmentid=113|

+-------------------------------------------------------------------+

--
MakeLei

------------------------------------------------------------------------
MakeLei's Profile: 'The Code Cage Forums - View Profile: MakeLei'

(http://www.thecodecage.com/forumz/member.php?userid=242)
View this thread: 'Looping help needed - The Code Cage Forums'

(http://www.thecodecage.com/forumz/sh...ad.php?t=86323)




--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=86323