返回列表 上一主題 發帖

請幫忙看一下插入欄這個程式問題出在哪

回復 1# Genie

你的意思不知是否如此
  1. Sub InsertColumn()
  2. Dim k
  3. r = ActiveCell.Row
  4. 10
  5. k = InputBox("輸入欲插入欄數", "插入欄數", 1)
  6. If Not IsNumeric(k) Then MsgBox "請輸入有效數值 ": GoTo 10
  7. i = Cells(r, 256).End(xlToLeft).Column
  8. Do Until i = 2
  9. If Cells(r, i) <> Cells(r, i - 1) And Cells(r, i - 1) <> "" And Cells(r, i) <> "" Then Cells(r, i).EntireColumn.Insert
  10. i = i - 1
  11. Loop
  12. End Sub
複製代碼
學海無涯_不恥下問

TOP

回復 8# Genie
忘了有多欄要求
  1. Sub InsertColumn()
  2. Dim k
  3. r = ActiveCell.Row
  4. 10
  5. k = InputBox("輸入欲插入欄數", "插入欄數", 1)
  6. If Not IsNumeric(k) Then MsgBox "請輸入有效數值 ": GoTo 10
  7. i = Cells(r, 256).End(xlToLeft).Column
  8. Do Until i = 2
  9. If Cells(r, i) <> Cells(r, i - 1) And Cells(r, i - 1) <> "" And Cells(r, i) <> "" Then Cells(r, i).Resize(, k).EntireColumn.Insert
  10. i = i - 1
  11. Loop
  12. End Sub
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 謊言像一朵盛開的鮮花,外表美麗,生命短暫。
返回列表 上一主題