在Excelmacros中,如何接受用户的列select?

在Excelmacros中,如何接受用户对列的select,然后将该列复制到新的Excel表中,然后重复执行多个列的过程(如7)?

编辑:

使用brettdj的答案结合糊状提供的链接我得到了这个,做了这个工作:

Dim rng1 As Range Dim NewBook As Workbook Set rng1 = Application.InputBox("Please select a column", "User selection - entire column will be copied", Selection.Address, , , , , 8) If Not rng1 Is Nothing Then Set NewBook = Workbooks.Add rng1.EntireColumn.Copy NewBook.Worksheets("Sheet1").[a1] End If 

使用Application.InputBox ,就像这样

 Sub TrySomethingNextTime() Dim rng1 As Range Dim ws As Worksheet On Error Resume Next Set rng1 = Application.InputBox("Please select a column", "User selection - entire column will be copied", Selection.Address, , , , , 8) On Error Goto 0 If Not rng1 Is Nothing Then Set ws = Sheets.Add rng1.EntireColumn.Copy ws.[a1] End If End Sub 

这是如此轻松和美丽! 谢谢…但你怎么做的行?! 您select的行。 我自己去吧。 那将是我的圣杯! 这是辉煌! 适应行:

  Sub TrySomethingNextTime2() Dim rng1 As Range Dim ws As Worksheet On Error Resume Next Set rng1 = Application.InputBox("Please select a row", "User selection - entire row will be copied", Selection.Address, , , , , 8) On Error GoTo 0 If Not rng1 Is Nothing Then Set ws = Sheets.Add rng1.EntireRow.Copy ws.[a1] End If End Sub