+ Reply to Thread
Results 1 to 1 of 1

macro to copy rows to another sheet based on condition mentioned in another workbook

  1. #1
    Registered User
    Join Date
    01-07-2013
    Location
    pune
    MS-Off Ver
    Excel 2010
    Posts
    1

    macro to copy rows to another sheet based on condition mentioned in another workbook

    I need a macro to copy rows from sheet1 to sheet2 of TESTCASE SAMPLE.xls based on condition specified in column O of sensitive sheet.xls and also this macro should update the value of TABLENAME in column A of TESTCASE SAMPLE.xls with the values specified in column (column no. will be an input to the macro) in sensitive.xls
    This is how this should work:
    Column no. using which TABLENAME is to be obtained from user (only once)and TABLENAME in column A of TESTCASE SAMPLE.xls should be replaced.
    If column O = *NAME* or %NAME% (note % and * represent any value following NAME)
    Then copy rows 2 to 11 from sheet 1 to sheet2
    If column O =*SSN*
    Then copy rows 12 to 23 from sheet1 to sheet2
    If column O = *Free Text*
    Then copy rows 26 to 31 from sheet1 and paste it to sheet2
    If column O = *ACCOUNT NUMBER*
    Then copy rows 24 and 25 from sheet1 to sheet2
    At the end for each value in column in Sensitive.xls(column used for updating TABLENAME), rows 32 and 33 are to be pasted to sheet2.
    Example:
    Find the following attachments: sensitive.xls, testcases.xls, TESTCASE SAMPLE.xls
    Column B will be provided as input by USER to update TABLENAME in column A in TESTCASE SAMPLE.xls
    Have attached testcases.xls, sheet2 contains the expected result once macro is run.
    Step1:
    1. For no. 13, TABLENAME is to be replaced by H2588TS.G.R1S0051.S88R1005.H2588R1A.TEST obtained from column B in sensitive.xls
    2. In column O, NAME,SSN,FREE TEXT are mentioned, so rows 2 to 11, rows 12 to 23, rows 26 to 31 are copied from sheet 1 to sheet2. Also rows 32 and 33 are copied(marked in red in testcase.xls)
    3. For no. 17, TABLENAME is replaced by H2588TS.G.R2S0051.S88R2005.H2588R2A.TEST
    4. Column O has values NAME,SSN,FREE TEXT,ACCOUNT NUMBER, so rows 2 to 11, rows 12 to 23, rows 26 to 31 and rows 24,25 are copied from sheet 1 to sheet2. Also rows 32 and 33 are copied(marked in blue in testcase.xls)
    5. For no.21, TABLENAME is replaced by H2588TS.G.R2S0154.S88R2015.H2588R2F.TEST
    6. Column O has NAME and SSN, so rows 2 to 11, rows 12 to 23 25 are copied from sheet 1 to sheet2. Also rows 32 and 33 are copied(marked in green in testcase.xls)
    Attached Files Attached Files

+ 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