+ Reply to Thread
Results 1 to 5 of 5

Update Code to work between 2 files

  1. #1
    Registered User
    Join Date
    09-13-2003
    Posts
    7

    Update Code to work between 2 files

    How do I update the following code and any code to work between 2 files. I will run the program from the original document (called "Rundw") within sheet1. I need to move sheets 11 - 14 to another file called "Run_database"
    "For i = 11 To 14
    Set rng = Sheets("Sheet " & i).Range(rngArray(i - 11))"

    Sub test2()
    Dim r As Range, c As Range, rngArray, Data As Range, rng As Range
    Dim i As Integer, ii As Integer
    Set Data = Sheets("sheet1").Range("ck133:dt144")
    rngArray = Array("D5:IT7", "D5:IT28", "D5:IT144", "D5:IT645")
    For i = 11 To 14
    Set rng = Sheets("Sheet " & i).Range(rngArray(i - 11))
    For ii = 1 To rng.Columns.Count Step 2
    For Each r In rng.Columns(i)
    Set c = Data.Find(what:=r.Value, looat:=xlWhole)
    If Not c Is Nothing Then r.Offset(, 1) = r.Offset(, 1) + 1
    Next
    Next
    Next
    End Sub

    Here is the same reference from another code that needs to be updated the way
    "a = Sheets("sheet " & 11 + n).Range(rngArray(n)).Value"
    Last edited by dkenebre; 08-11-2005 at 01:33 PM.
    dK

  2. #2
    JGeniti
    Guest

    Re: Update Code to work between 2 files

    Have you tried creating an Add-In that houses all of your code and then
    referencing the Add-In from each file?


  3. #3
    Registered User
    Join Date
    09-13-2003
    Posts
    7
    No I have not done that, However, that sounds like an interesting concept. How do I do I set it up, according to my posted example?
    and does this mean I would not have to change/update the code, just have both files open at the same time while executing the code?
    Last edited by dkenebre; 08-11-2005 at 02:32 PM.

  4. #4
    JGeniti
    Guest

    Re: Update Code to work between 2 files

    The best way to utilize an add-in would be to open up a blank workbook
    and transfer all of your code from the original workbook.

    Save the new workbook as an .xla file. This makes it an add-in.
    Then you would need to go into your original workbooks and delete all
    of the code so that it doesn't conflict with the add-in.
    Once the code is deleted you will need to go to Tools > References and
    browse for the new add-in file that you just created.

    You will need to setup the reference for all of the workbooks that you
    would like to utilize the code library in the add-in.

    Hopefully this was helpful.
    James


  5. #5
    Registered User
    Join Date
    09-13-2003
    Posts
    7
    Thanks for the update. Can I just copy, then delete the code as instructed for only the codes that I want to work between the 2 files and leave the remaining code within the original workbook and the procedure will still work?

+ Reply to Thread

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