跳到主要內容

如何在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列。 看截圖:

備註:您可以在第二個中指定數字 Kutoolsfor Excel 對話框來滿足您的需求。

但是有時候,您需要選擇兩個間隔為兩列的列。 上面的代碼無法正常工作,應該怎麼辦?


用Kutools for Excel選擇第n列

Excel的Kutools:具有300多個方便的Excel加載項,可以在30天內免費試用,沒有任何限制。 立即獲取。

這款獨特的敏感免洗唇膜採用 Moisture WrapTM 技術和 Berry Mix ComplexTM 成分, Excel的Kutools,您可以按特定的間隔選擇特定的列數。 請按照以下步驟操作:

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選項卡為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