Write your own macros so that Excel2007 cells or columns move left and right

Source: Internet
Author: User

① Click the menu bar-view-macros-to view the macros.

② Pop-up Macro interface, enter the name of the macro, here to facilitate memory, we named to move one column to the left, and then click the Create button.

③ in the new appearance of the interface, the input code, that is, the program language, I have written, you can copy directly.

application.screenupdating = False

x = Selection.column

If x >= 1 Then

Columns (x). Cut-and

Columns (x-1). Insert

application.screenupdating = True

End If

④ exit the edit state, select the cell or the entire column, and execute the macro. Below, I'll move the right one column of code also to everyone.

application.screenupdating = False

x = Selection.column

If x < 256 Then

Columns (x). Cut-and

Columns (x + 2). Insert

End If

application.screenupdating = True

End 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.