+ Reply to Thread
Results 1 to 3 of 3

Importing Data from Worksheet depending on matching column values

  1. #1
    Registered User
    Join Date
    10-20-2010
    Location
    Berlin
    MS-Off Ver
    Excel 2003
    Posts
    39

    Exclamation Importing Data from Worksheet depending on matching column values

    I have uploaded a comprehensive real version of my project to show you what I want the macro to do exactly.

    Here are some rules for the macro (explained thoroughly):
    - Go through each cell in sheet1 column C and match it with the value in sheet2 column A. if a match is found then copy the data from the declared columns in sheet1 and paste them to the declared columns in sheet2.
    - if a value in sheet1 column C is not present in sheet2 col A, then insert that row with that value in sheet2 col A, and import the data from the respective columns (as above).
    - If a certain value in sheet1 col C occurs X times, and that same value in sheet2 col A occurs Y times, then it means X nr. of times must the data be overwritten to sheet2 (according to the rules below).

    X(1) = first row of a value occurring in sheet 1 col C . X(2), X(3).... etc
    Y(1) = first row the same value occurs in sheet2 col A . Y(2), Y(3)...... etc
    Data flow path:
    columns of X(1) -> columns of Y(1)
    columns of X(2) -> columns of Y(2)
    ... and so on

    Cases:
    X>Y : overwrite data X times to the respective row position of same value in sheet2. X-Y nr. of new blank rows created (below existing row(s) of that value with that value then entered in sheet2 col A) to accommodate new data coming from columns of sheet1
    X=Y: no new rows needed. overwrite data X times in sheet2
    X<Y : no new rows needed. overwrite data X times in sheet2. the remaining rows (Y-X) remain the same.

    - Overwriting rules: if before pasting the data in sheet2, the respective cell contains no data then simply paste the value in that cell. if that cell contains the same data to be pasted then just paste it into that cell (or do nothing). if the data in that cell is different to the data to be pasted then save the old data as a comment in that cell and paste the new data.


    How I approached this:
    - I started off with a macro to create new rows depending on the multiple occurring same value i compared between sheet1 col C and sheet2 col A
    http://www.ozgrid.com/forum/showthread.php?t=147485
    - After the new rows were inserted at the bottom of the worksheet , i used the auto filter to sort the values in sheet2 col A by ascending order. now the new rows were below the original rows for every value. you may just want to create the new rows (depending on the cases for X and Y) below the existing row(s) when needed.
    - Now I ran the macro to import data from the declared columns in sheet1 and put it in the declared columns in sheet2 .
    http://www.ozgrid.com/forum/showthread.php?t=147461
    Here the code only works for the first time entry of the same value i.e data from the columns in the row of X(1) goes to the columns of the row of Y(1). Y(1), (Y2) ,etc.. remain the same , or in the case of the new rows inserted , they stay blank. (so you need to modify the code as i described above).

    I hope this helps. Please let me know if you need any more information.

    Cheers,
    JN
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    10-20-2010
    Location
    Berlin
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: Importing Data from Worksheet depending on matching column values

    Posting here:
    http://www.mrexcel.com/forum/showthread.php?t=506690

  3. #3
    Registered User
    Join Date
    10-20-2010
    Location
    Berlin
    MS-Off Ver
    Excel 2003
    Posts
    39

    Re: Importing Data from Worksheet depending on matching column values

    Similar thread:
    http://www.ozgrid.com/forum/showthre...=147461&page=1

+ 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