[算表] VBA如何依分類插入空白列
軟體:Excel
版本:2007/2010
我的工作表如下:
日期 客單編號
================
5/18 A
5/18 A
5/18 B
5/18 B
5/18 B
5/18 C ←我想依客單編號後面加入空白列
5/18 C
希望能變成:
日期 客單編號
================
5/18 A
5/18 A
(空白列)
5/18 B
5/18 B
5/18 B
(空白列)
5/18 C
5/18 C
(空白列)
經查網路VBA模組可以讓每一列插入空白列
但我需要的是依分類去插入空白
不知道程式碼該怎麼修改
再請版上大大指導一下
感謝!
檔案如下:
https://goo.gl/ihCTvB
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.24.153.3
※ 文章網址: https://www.ptt.cc/bbs/Office/M.1526658726.A.BBF.html
→
05/19 00:02,
7年前
, 1F
05/19 00:02, 1F
→
05/19 00:02,
7年前
, 2F
05/19 00:02, 2F
→
05/19 00:02,
7年前
, 3F
05/19 00:02, 3F
→
05/19 00:02,
7年前
, 4F
05/19 00:02, 4F
→
05/19 00:04,
7年前
, 5F
05/19 00:04, 5F
→
05/19 00:04,
7年前
, 6F
05/19 00:04, 6F
原程式碼如下,不知道改怎麼修改?
Dim IntCount As Integer
IntCount = Application.WorksheetFunction.CountA(Range("A:A")) - 1
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
ActiveCell.FormulaR1C1 = "temp"
Range("A2").Select
ActiveCell.FormulaR1C1 = "1"
Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Stop:=IntCount, Trend:=False
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("工作表1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("工作表1").Sort.SortFields.Add
Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("工作表1").Sort
.SetRange ActiveCell.Range("A2:N" & (IntCount * 2))
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveCell.Columns("A:A").EntireColumn.Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Select
※ 編輯: nash30113 (114.24.153.3), 05/19/2018 00:10:10
→
05/19 00:09,
7年前
, 7F
05/19 00:09, 7F

→
05/19 00:11,
7年前
, 8F
05/19 00:11, 8F
→
05/19 00:12,
7年前
, 9F
05/19 00:12, 9F
→
05/19 00:14,
7年前
, 10F
05/19 00:14, 10F
→
05/19 00:39,
7年前
, 11F
05/19 00:39, 11F
→
05/19 00:40,
7年前
, 12F
05/19 00:40, 12F

→
05/19 00:40,
7年前
, 13F
05/19 00:40, 13F
→
05/19 12:13,
7年前
, 14F
05/19 12:13, 14F
Office 近期熱門文章
PTT數位生活區 即時熱門文章