编写宏让Excel2007单元格或者整列左移右移 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【www.unjs.com - 电脑资料】

    ①单击菜单栏--视图--宏--查看宏,

编写宏让Excel2007单元格或者整列左移右移

   

    ②弹出宏的界面,输入宏的名称,这里为了便于记忆,我们命名为向左移动一列,然后点击创建按钮。

   

    ③在新出现的界面中,输入代码,也就是程序语言,我已经写好了,大家直接复制即可。

    Application.ScreenUpdating = False

    x = Selection.Column

    If x >= 1 Then

    Columns(x).Cut

    Columns(x - 1).Insert

    Application.ScreenUpdating = True

    End If

   

    ④退出编辑状态,选中单元格或者整列,执行宏即可,

电脑资料

编写宏让Excel2007单元格或者整列左移右移》(https://www.unjs.com)。下面,我把向右移动一列的代码也给大家。

    Application.ScreenUpdating = False

    x = Selection.Column

    If x < 256 Then

    Columns(x).Cut

    Columns(x + 2).Insert

    End If

    Application.ScreenUpdating = True

    End Sub

   

最新文章