If Worksheet 1 and Worksheet 2 Match, copy to worksheet 3 - Excel Formula

时间:2015-07-28 23:40:08

标签: excel excel-formula

I am trying to figure out how to create the following in excel using formula as I am not familiar with VBA.

I have worksheet 1 which contains all the accounts numbers relating to different companies, these are unique keys

Worksheet 2 contains all the users in the account which also have the account ID.

I want the 3 worksheet to see if account ID in worksheet 1, look at worksheet 2 if match copy column 1,2,3 across.

E.G.

Worksheet 1 = Column A2 contains Account ID 1234 | Worksheet 2 = Column A2 contains Account ID 1234, B2 = First Name, C2 = Last Name | Worksheet 3 = I want A2 = 1234, B2 = First Name, C2 = Last Name

1 个答案:

答案 0 :(得分:0)

I think I understand what you are trying to achieve. In Sheet3, you want a list of account IDs from column A in Sheet1. That account ID is used to check for a matching account ID in Sheet2 and return the values from columns B and C.

In Sheet3's A2 use the following formula,

function replaceDOMText(str, replaceWith) {
    $('body:contains(' + str + ')').contents().each(function() {
        if (this.nodeType == 3) {
            $(this).parent().html(function(_, oldValue) {
                return oldValue.replace(RegExp(str, "g"), replaceWith);
            })
        }
    });
}


// Call like this
replaceDOMText("866.264.1842", "888.888.4754" );

In Sheet3's B2 use the following formula,

=sheet1!A2

Copy or fill that right to C2 then fill A2:C2 down as far as you wish.