Import VBA Excel phone number (sheet1 to sheet2)

Source: Internet
Author: User

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

 


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.