+ Reply to Thread
Results 1 to 4 of 4

Loop code through two works

  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?


    Please Login or Register  to view this content.
    thanks for any assistance
    Last edited by mrsak87; 09-18-2020 at 06:38 AM.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Loop code through two works

    You don't have to activate each workbook to copy from one and paste to the other as long as you fully reference the copy location and paste location. The following code is an example. It copies A1 from the "SourceSheet" in the workbook containing the macro to A1 of the "DestSheet" in the "Test.xlsx" workbook. Without seeing your two files, it's hard to suggest a solution. It would be easier to help and test possible solutions if you could attach copies of your files. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file.
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

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

    Re: Loop code through two works

    Thank you mumps!

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,777

    Re: Loop code through two works

    You are very welcome.

+ Reply to Thread

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