跳到主要内容

如何在Excel中选择第n列?

例如,您有一个包含数百列数据的大型工作表。 现在,您需要复制每第3列数据并将其粘贴到另一个新工作表中。 逐个选择第n列会很耗时,有没有简便的方法?

使用VBA选择第n列

使用 Kutools for Excel 选择每 n 列


箭头蓝色右气泡 使用VBA选择第n列

除了VBA代码,似乎没有简单的方法可以解决此问题。 请按照以下步骤操作:

1.突出显示要在第n列中选择的范围。

2.Click 开发商 > Visual Basic中 或按 Alt + F11,一个新的 适用于应用程序的Microsoft Visual Basic 将显示一个窗口,单击 插页 > 模块 将以下代码输入到模块中:

 

Sub EveryOtherColumn()
'Updateby20140314
Dim rng As Range
Dim InputRng As Range
Dim OutRng As Range
Dim xInterval As Integer
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
xInterval = Application.InputBox("Enter column interval", xTitleId, Type:=1)
For i = 1 To InputRng.Columns.Count Step xInterval + 1
    Set rng = InputRng.Cells(1, i)
    If OutRng Is Nothing Then
        Set OutRng = rng
    Else
        Set OutRng = Application.Union(OutRng, rng)
    End If
Next
OutRng.EntireColumn.Select
End Sub

3。 然后点击  按钮运行代码,然后会弹出一个提示框,提醒您选择要使用的范围。 看截图:

 

4。 点击 OK,然后在另一个弹出对话框中输入间隔数。 在这种情况下,请在框中输入3。 看截图:

5。 点击 OK。 现在,它选择所选内容中的每第3列。 看截图:

备注:您可以在第二个中指定数字 KutoolsForexcel. 对话框来满足您的需求。

但是有时候,您需要选择两个间隔为两列的列。 上面的代码无法正常工作,应该怎么办?


使用 Kutools for Excel 选择每 n 列

Kutools for Excel:具有300多个方便的Excel加载项,可以在30天内免费试用,没有任何限制。 立即获取。

Kutools for Excel,您可以按特定的间隔选择特定的列数。 请按照以下步骤操作:

1.Click 库工具 > 选择工具 > 选择间隔行/列,请参见屏幕截图:

2。 “ 选择间隔行/列 对话框出现。 然后点击 按钮选择所需范围,然后选择选择部分,然后在 间隔 下拉列表,这里我们在每3td列中选择两列。 看截图:

3.Click OK。 它将在选择中以两个间隔选择两列。 看截图:

备注:如果您检查 选择整列 在弹出对话框中,它将选择工作表中的整个列。 看截图:


相关文章:

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!

 

Comments (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I have one issue in excel, for example, in a row first five sells are numbered as 1,2,3, 4,5. in the second row also numbered as 1,2,3,4,5 in each sell. then to the third row need to paste the values of above two rows alternatively. means i need answer in each sells in third row 1,1,2,2,3,3,4,4,5,5. how can I do easily in excel? I am waiting for your response because I need to complete big datasheet.
This comment was minimized by the moderator on the site
i need to copy from f18 to h19, then f21 to h22, and it goes on till 500 values and before the value in h column need to add text also

like f18 = 345

in h19 I should get = tdg 345

for 500 values in h column.

please help me someone
This comment was minimized by the moderator on the site
This macro sucks dont waste your time
This comment was minimized by the moderator on the site
For some reason this does not work if only one row is selected.
This comment was minimized by the moderator on the site
Excel 2010 - Select interval column command does not work. There is no any raction after clicking - ok
This comment was minimized by the moderator on the site
I always get an error: invalid procedure... How can I solve it. I want to select every 4th column in my dataset
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations