Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

head spinning loop...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stephen - 23 Nov 2007 21:49 GMT
At least it's making my head spin...

Sheet1 has sections so that A32 - A81 is part of one section.  I want to
loop through all the values in Sheet2, column D and if those values begin
with "6" then take the value from the same row in column E and place it in
Sheet1 starting from row A32 and filling downward for every instance in
Sheet2 where the value begins with "6".

Please help!
Jim Thomlinson - 23 Nov 2007 22:28 GMT
Give this a try...

Sub CopyStuff()
   Dim rngToSearch As Range
   Dim rngFound As Range
   Dim rngFoundAll As Range
   Dim strFirstAddress  As String
   
   Set rngToSearch = Sheets("Sheet2").Columns("D")
   Set rngFound = rngToSearch.Find(What:="6*", _
                                   LookAt:=xlWhole, _
                                   LookIn:=xlFormulas)
   If Not rngFound Is Nothing Then
       Set rngFoundAll = rngFound
       strFirstAddress = rngFound.Address
       Do
           Set rngFoundAll = Union(rngFound, rngFoundAll)
           Set rngFound = rngToSearch.FindNext(rngFound)
       Loop Until rngFound.Address = strFirstAddress
       rngFoundAll.Offset(0, 1).Copy Sheets("Sheet1").Range("A32")
   End If
End Sub
Signature

HTH...

Jim Thomlinson

> At least it's making my head spin...
>
[quoted text clipped - 5 lines]
>
> Please help!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.