Excel宏移动列 [英] Excel macro to move column

查看:152
本文介绍了Excel宏移动列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我希望将一个位置的列移动到另一个位置.

Basically I'm looking to move a column for one position to another.

561  DISK_GROUP_003 0   545     1
561  Disk_Group_iS  95  84144   80210
561  DISK_GROUP_iS  99  26335   26304
1415    t1_200ea    93  8804    8203
1415    t2_30010k   35  59846   21121
1415    t3_1tb72k   19  184941  36590
1415    t3_3tb72k   86  258635  224328
5018    t1_200ea    98  9905    9802
5018    t2_30015k   89  39987   35986
5018    t2_60015k   67  59984   40700
5018    t3_1tb72k   89  87567   78807
5018    t3_2tb72k   84  94412   79620

我需要将第3列移到右侧的末尾.

I need to move the 3rd column to the end at the right.

这是我到目前为止尝试过的:

This is what I have tried so far:

Sub moveColumn()

With ActiveSheet        
        Excel.Columns(3).Cut
        Excel.Columns(6).PasteSpecial
End With

End Sub

但是此方法不起作用,因为它遇到运行时错误'1004'.

But this method doesn't work as it gets a runtime error '1004'.

任何帮助将不胜感激.

推荐答案

Pastespecial不适用于Cut.您可以这样做:

Pastespecial doesn't work with Cut. You can do this:

Columns(3).Cut Range("F1")
Columns(3).Delete Shift:=xlToLeft 'if you want to delete the empty column

这篇关于Excel宏移动列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆