+ Reply to Thread
Results 1 to 11 of 11

Linking togather two documents using a macro

  1. #1
    Registered User
    Join Date
    02-21-2012
    Location
    Ploiesti
    MS-Off Ver
    Excel 2007
    Posts
    8

    Linking togather two documents using a macro

    Hello ,
    My boss asked me to write a macro so two of our departments can use , he asked me to:

    -Add the values from every cell in worksheet 1 (document A) to the coresponing cells in worksheet 1 (document B) , in plain terms i have to copy the data from one document into the other via a macro
    *in case one of the cells is missing the value it should be automaticly added from the first document
    ** If one document sheet(or cell) is to be modified the other cells in the second document automaticly change - like being linked togather

    I have no programing background and I've only recently started learning the VBA tutorial , this seems complicated to me .
    What I've managed to do so far is to read a number from e.g Sheet1.A1 and copy it to Sheet2.B1 (within THE SAME DOCUMENT/WORKSHEET)

    PS: Both the documents are different in structure , the first one has concentrated data ( like the values from two cells in document B are in one cell in document A) , where the other has values seperatly
    e.g pressure + temperature = one cell in worksheet 1 (document A) , document B has pressure = one cell , temperature = one cell

    Hope i get some assistence , I'm sorry if i posted in the wrong (sub)forum

    Best regards,

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Linking togather two documents using a macro

    Why dont you attach a sample of both the files? So we can understand the layout.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    02-21-2012
    Location
    Ploiesti
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Linking togather two documents using a macro

    F058_H00-N008_00_Armaturenliste.xlsArmaturenliste 07.02.2012.xls

    Here you go

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Linking togather two documents using a macro

    Can you explain in detail where you need help?

  5. #5
    Registered User
    Join Date
    02-21-2012
    Location
    Ploiesti
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Linking togather two documents using a macro

    As you can see the Tag Name and number in the first column is the same in both documents , but if i decide to change the tag number in the first document which is in the first column it should then change the tag name in the first column of the second document (again if this is actually possible). The yellow higlited cells in the first document are not in the second document therefor it isn't needed for them to be linked.
    On the other hand columns like DN(nominal diameter , value expressed in inches) should again be the same in both documents , but some of the cells are empty in the second document , that should be automaticly filled and corrected(in case it is modified) by the MACRO.

    Due to the fact that i'm a begginer in such matters , i've requested the help of the forum and i'm trying really hard to figure this out by my own but some things just don't make sense to me (for the moment).
    Please Login or Register  to view this content.
    The code above should give a general idea of what i need except it's only aplied (from what i've read so far) only in the same worksheet.
    The main idea is to have the 2 documents basicly mashed up into one even tho they are separated (for two of the departments to use)
    Last edited by Robertg; 02-21-2012 at 08:23 AM.

  6. #6
    Registered User
    Join Date
    02-21-2012
    Location
    Ploiesti
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Linking togather two documents using a macro

    So any advice?

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Linking togather two documents using a macro

    Some observations are - Your first file has the TAG name split into 2 columns. Also your 2nd file has more data in terms of rows than the 1st.

    In this case, we can have a macro setup which will clear the contents of one of the files and copy the data over (depending on which columns are required) from one file to the other.

    You can choose which file should be blanked out and started from scratch, since you know the data well. The formats dont match so only you can let me know.

  8. #8
    Registered User
    Join Date
    02-21-2012
    Location
    Ploiesti
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Linking togather two documents using a macro

    Regarding your observations:

    -i know the tag name is splint into 2 columns , the document was designed that way to be more compact than the second , it still HAS the same numbers as the second document , i only need to use the values in the cells.
    *Is it impossible to use lets say columnA+B (worksheet 1) to add the values from the both cells , which make up the TAG , in the second worksheet (2)?
    -clear example : [CV](column 1) + [1101](column 2) ->[CV-1101](column 1 , worksheet 2) ?
    - regarding the format : we can make the font the same in both (let's say arial 8) , but they can't be the same in structure
    *the entire point is for the macro is for the worksheets to be used separately , one department uses the first , the other dpt uses the second...
    In this case, we can have a macro setup which will clear the contents of one of the files and copy the data over (depending on which columns are required) from one file to the other.

    You can choose which file should be blanked out and started from scratch, since you know the data well. The formats dont match so only you can let me know.
    The contents should not be cleared in one and copied in the other , the contents of the column&rows should be the same in both documents regardless of the format.
    *if i have 3 colums with 4 rows in the first worsheet and 5 colums with 7 rows in the second worksheet i should have the same values in the cells if the first 3 colums and rows in the second document have the same meaning/name/numbers as the first one.
    ** in my case the first row of worksheet 1 is equivalent to the first 4 rows of the second worksheet , the tag name is simply compact in the first document.

    I hope this is't as confusig for you as it is for me , I'm trying to explain this as clear as I can be.

    Thanks for the help so far,

  9. #9
    Registered User
    Join Date
    02-21-2012
    Location
    Ploiesti
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Linking togather two documents using a macro

    I've been burning through tutorials so far, still not close to what i need :<
    Maybe a macro to compare two cells and add a value in one of them in case it's missing?

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Linking togather two documents using a macro

    The contents should not be cleared in one and copied in the other , the contents of the column&rows should be the same in both documents regardless of the format.
    I didnt mean this. What i meant was...we can clear the contents of say workbook 1 for example. Then load fresh data from workbook2 depending on the headers.

    Will this work?

  11. #11
    Registered User
    Join Date
    02-21-2012
    Location
    Ploiesti
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Linking togather two documents using a macro

    Yes , it will 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