Results 1 to 11 of 11

[SOLVED] Identical code, different output - reading from two different Excel files

Threaded View

  1. #1
    Registered User
    Join Date
    01-03-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    17

    [SOLVED] Identical code, different output - reading from two different Excel files

    Dear members,

    Sorry to disturb you again. I have two code snippets that are identical (except for one variable name):

    Snippet 2
            For i = 2 To Application.CountA(Range("A:A"))
                For j = 2 To Application.CountA(Range("A:A"))
                    If TO_Sheet_OFA.Range("A" & i) = Filename_TO.Sheets("Extra_days").Range("A" & j) Then
                        TO_Sheet_OFA.Range("F" & i) = Filename_TO.Sheets("Extra_days").Range("B" & j)
                    End If
                Next j
            Next i
    Snippet 1
            For i = 2 To Application.CountA(Range("A:A"))
                For j = 2 To Application.CountA(Range("A:A"))
                    If TO_Sheet_CTO.Range("A" & i) = Filename_TO.Sheets("Extra_days").Range("A" & j) Then
                        TO_Sheet_CTO.Range("F" & i) = Filename_TO.Sheets("Extra_days").Range("B" & j)
                    End If
                Next j
            Next i
    Snippet 1 works, and copies the right information. Snippet 2 doesn't work, as column F remains empty after the code has been executed.
    My suspicion at first that the source file (Filename_From, not shown in the text above) might be corrupted. I recreated the file, but that did not help.

    I have attached the two code files in their entirity below. What are your theories?

    EDIT: added workbooks.
    Attached Files Attached Files
    Last edited by nErD; 01-04-2012 at 08:46 AM. Reason: Adding files

Thread Information

Users Browsing this Thread

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

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