Ben*_*Ben 5 excel vba rollup blank-line
我在下面创建了一个与excel中的表格类似的示例表,它应该用于说明问题.我想在column1中的每个不同数据之后添加一行(最简单的方法,使用excel,谢谢).
_
column1 | column2 | column3
----------------------------------
A | small | blue
A | small | orange
A | small | yellow
B | med | yellow
B | med | blue
C | large | green
D | large | green
D | small | pink
Run Code Online (Sandbox Code Playgroud)
_
注意:每个不同列1后面的空行
column1 | column2 | column3
----------------------------------
A | small | blue
A | small | orange
A | small | yellow
B | med | yellow
B | med | blue
C | large | green
D | large | green
D | small | pink
Run Code Online (Sandbox Code Playgroud)
Our*_*nas 17
这完全符合您的要求,检查行,并在A列的每个更改中插入一个空行空行:
sub AddBlankRows()
'
dim iRow as integer, iCol as integer
dim oRng as range
set oRng=range("a1")
irow=oRng.row
icol=oRng.column
do
'
if cells(irow+1, iCol)<>cells(irow,iCol) then
cells(irow+1,iCol).entirerow.insert shift:=xldown
irow=irow+2
else
irow=irow+1
end if
'
loop while not cells (irow,iCol).text=""
'
end sub
Run Code Online (Sandbox Code Playgroud)
我希望能让你开始,让我们知道!
菲利普
归档时间: |
|
查看次数: |
167101 次 |
最近记录: |