Results 1 to 4 of 4

Loop code through two works

Threaded View

  1. #1
    Forum Contributor
    Join Date
    03-05-2015
    Location
    norwich
    MS-Off Ver
    365
    Posts
    107

    Loop code through two works

    Hi,

    I was wonding if you could help me out with some code efficiency. I have two workbooks - One I cycle through to find an existing result, the second I paste in the correct place. However I can't get it to work without using "DestWB.Activate" and "SrcWB.activate" to copy/paste once the result is found. This cycling between workbooks is the slowest bit of the code. Is there a more efficient way?


    Sub HorizonImportSched()
    
    'code for source workbook =SrcWB and destination workbook = DestWB
    
                'Find DestWb and paste above
                        DestWB.Activate
                        
                        With Range("C13:C" & LastDest)
                        Set EnterT = Cells.Find(What:=Cell, after:=ActiveCell, LookIn:=xlValues, LookAt _
                        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                        True, SearchFormat:=False)
                            
                            If Not EnterT Is Nothing Then
                                
                                Cells.Find(What:=Cell, after:=ActiveCell, LookIn:=xlValues, LookAt _
                                    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
                                    True, SearchFormat:=False).Select
                                
                                Selection.Offset(0, 10 + Di).Select
                                ActiveSheet.Paste
                                
                            End If
                        End With
                        SrcWB.Activate
    thanks for any assistance
    Last edited by mrsak87; 09-18-2020 at 06:38 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. I'm confused this loop works?
    By TestKing1994 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-12-2019, 04:13 PM
  2. Replies: 1
    Last Post: 07-02-2018, 07:32 PM
  3. [SOLVED] For Each Loop Works for Textboxes but Not for DTPickers.... why?
    By TheScott in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-03-2015, 06:01 AM
  4. how can i make this code works for multiple links it only works for one link
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-12-2014, 08:38 AM
  5. [SOLVED] if then loop works incorrectly - syntax?
    By canoehack in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-25-2013, 09:31 AM
  6. loop works for one but causes error for other data
    By gill389 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2011, 08:21 AM
  7. Code To Find and Offset works on first sheet but won't loop to other sheets
    By mgaworecki in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-10-2009, 03:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1