简体   繁体   English

将 Excel 选择移动到第一列(偏移?)

[英]Move Excel Selection to first column (offset?)

How do I move my current selection to the first column of the sheet retaining the same rows.如何将当前选择移动到工作表的第一列保留相同的行。 Example - Current selection - D3,D4,D6 selection moved to A3,A4,A6 (Columns of the current selection will change and not the same as D)示例 - 当前选择 - D3、D4、D6 选择移动到 A3、A4、A6(当前选择的列将更改且与 D 不同)

Selection.Offset(x, x).Select

Can I use the selection offset?我可以使用选择偏移量吗?

If you want to do it with Offset you can do it like that:如果你想用Offset来做,你可以这样做:

Sub test()

Dim x As Long
x = Selection.Column
Selection.Offset(0, -x + 1).Select

End Sub

x is the column of your current selection, take this amount of column out to go to the first column. x 是您当前选择的列,将这一列数量取出到第一列。

Could you perhaps do something like this?你能不能做这样的事情? A cut and insert in macro form.宏形式的切割和插入。 Replace the strings with your selection.用您的选择替换字符串。

Columns("B").Cut
Columns("F").Insert Shift:=xlToRight

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM