插入excel中每个表的百分比后的行
我有大约100张桌子 我需要在每个%之后为每个表插入一行。 我怎样才能使用Excelmacros?
'Total `Banglore` `Delhi`
Q1。 年龄
Base
'653
'77'
'86'
18-19'35''15 '35'
'22'
'5% '19% '26%'
20-24
'216'
'30'
'33'
'33% '3 '38%'
谢谢,
Tanuvi
这可能会有所帮助: 编辑一些意见添加在OP请求。
Sub Insert_blank_rows() Dim i As Long Dim LastRow As Long 'this code will run from last till first row which is required when inserting rows 'here we check last not-empty row to know which point to start from LastRow = Cells(Rows.Count, 1).End(xlUp).Row 'start the loop from last not-empty direction first row For i = LastRow To 1 Step -1 'if first cell in row is empty and there are some other not-empty cells If Len(Cells(i, 1)) = 0 And Application.CountBlank(Rows(i)) <> Columns.Count Then 'we will insert empty row right below that row Rows(i + 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove End If Next i End Sub
一些信息:
– 它适用于活动工作表
– 我假设你的问题的第一列是你的工作表中的列A.
-code不检查行中是否有%符号,但是依赖于你传递的其他信息(行中的第一个单元格是空的,同一行中有一些其他单元格填充了值)
以下图片显示之前和之后的状态。