EXCEL vba 不能执行命令
附原码:Subtext()DimrngAsRange,b%b=Sheet1.UsedRange.Rows.CountMsgBoxbForEachrngInRange("a...
附原码:
Sub text()
Dim rng As Range, b%
b = Sheet1.UsedRange.Rows.Count
MsgBox b
For Each rng In Range("a1:a" & b)
If rng Like "*标题行*" Then
Rows(rng.Row).Insert
Rows(rng.Row + 1).Insert
End If
Next
End Sub
目的是在在A列含有“标题行”字符的行 上下各插入一个空行,可运行的时间鼠标就一直打转转,命令执行没有效果,请高手指点迷津 展开
Sub text()
Dim rng As Range, b%
b = Sheet1.UsedRange.Rows.Count
MsgBox b
For Each rng In Range("a1:a" & b)
If rng Like "*标题行*" Then
Rows(rng.Row).Insert
Rows(rng.Row + 1).Insert
End If
Next
End Sub
目的是在在A列含有“标题行”字符的行 上下各插入一个空行,可运行的时间鼠标就一直打转转,命令执行没有效果,请高手指点迷津 展开
3个回答
展开全部
Sub text()
Dim rng As Range, b%
b = Sheet1.UsedRange.Rows.Count
'MsgBox b
For i = 1 To 65535 Step 1 'Range("a1:a65535")
If Range("A" & i) Like "*标题行*" Then
b = b - 1
Rows(Range("A" & i).Row).Insert
Rows(Range("A" & i).Row + 2).Insert
i = i + 2
End If
If b = 0 Then Exit For
Next
End Sub
你的加行数不对,还有A列全局使用量b用错的。完全是不同的概念
Dim rng As Range, b%
b = Sheet1.UsedRange.Rows.Count
'MsgBox b
For i = 1 To 65535 Step 1 'Range("a1:a65535")
If Range("A" & i) Like "*标题行*" Then
b = b - 1
Rows(Range("A" & i).Row).Insert
Rows(Range("A" & i).Row + 2).Insert
i = i + 2
End If
If b = 0 Then Exit For
Next
End Sub
你的加行数不对,还有A列全局使用量b用错的。完全是不同的概念
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Sub text()
Dim rng As Range, b%
b = Sheet1.UsedRange.Rows.Count
inserRows = 0
For iRow = 1 To b
If Cells(iRow + inserRows, 1) Like "*标题行*" Then
Rows(iRow + inserRows + 1).Insert
Rows(iRow + inserRows).Insert
inserRows = inserRows + 2
End If
Next
End Sub
Dim rng As Range, b%
b = Sheet1.UsedRange.Rows.Count
inserRows = 0
For iRow = 1 To b
If Cells(iRow + inserRows, 1) Like "*标题行*" Then
Rows(iRow + inserRows + 1).Insert
Rows(iRow + inserRows).Insert
inserRows = inserRows + 2
End If
Next
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询