Excel mode:
Sheet1:
Sheet2:
Then select the tool-Macro-VB compiler: Add module writeCode:
Sub zxl_input_phone () set SH2 = worksheets ("sheet2") 'represents the sheet2 worksheet with an object variable r2 = sh2.range ("a65536 "). end (xlup ). row 'calculates the maximum row number of the data in column A of the sheet2 worksheet. worksheets ("sheet1 "). activate 'activate sheet1 worksheet R1 = range ("a65536 "). end (xlup ). row 'calculates the maximum row number of the data in column A of the sheet1 worksheet for I = 2 to r1'. xm1 = Replace (cells (I, 1 ),"","") 'Copy the name to the variable xm1 (remove space) for J = 2 to r1'. Perform a circular xm2 = Replace (sh2.cells (J, 1), "", "") on the sheet2 worksheet ),"","") 'assign the name to the variable xm2 (remove space) If xm2 = xm1 then' with the same name as cells (I, 2) = sh2.cells (J, 2) 'import the corresponding phone number exit for end if next nextend sub