Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 3580|回复: 7

[已解决][求助]vba自动插入空行

[复制链接]
发表于 2009-9-25 11:08 | 显示全部楼层 |阅读模式
我想在工作表里面的a列有数据的单元格下面插入一个空行,怎么处理,请高手指点
最佳答案
2009-9-29 00:15

给另一个向下插入行思路:

Private Sub InsertRow()

    Dim IR As Integer
    Dim rng As Range

    IR = ActiveCell.Row
    Set rng = ActiveCell


    rng.EntireRow.Copy    '复制行
    rng.EntireRow.Insert Shift:=xlUp    '插入复制的行
    rng.EntireRow.ClearContents     '清除复制内容

    Application.CutCopyMode = False    '取消选择区域


End Sub

发表于 2009-9-25 11:25 | 显示全部楼层
回复

使用道具 举报

发表于 2009-9-25 11:31 | 显示全部楼层

Sub yy()
i = 1
Do
If Cells(i, 1) <> "" Then Rows(i + 1).Insert: i = i + 1
i = i + 1
Loop Until i = Cells.Find("*", , , , 1, 2).Row
End Sub
回复

使用道具 举报

发表于 2009-9-25 11:47 | 显示全部楼层

学习3楼的方法 要是提示变量未定义 就在sub yy() 下边加上一句dim i as long
回复

使用道具 举报

发表于 2009-9-25 16:30 | 显示全部楼层

学习[em02][em02]
回复

使用道具 举报

发表于 2009-9-28 20:15 | 显示全部楼层

看看

回复

使用道具 举报

发表于 2009-9-29 00:15 | 显示全部楼层    本楼为最佳答案   

给另一个向下插入行思路:

Private Sub InsertRow()

    Dim IR As Integer
    Dim rng As Range

    IR = ActiveCell.Row
    Set rng = ActiveCell


    rng.EntireRow.Copy    '复制行
    rng.EntireRow.Insert Shift:=xlUp    '插入复制的行
    rng.EntireRow.ClearContents     '清除复制内容

    Application.CutCopyMode = False    '取消选择区域


End Sub

回复

使用道具 举报

发表于 2009-9-29 00:51 | 显示全部楼层

学习了,厉害,高手呀
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-15 23:48 , Processed in 0.296446 second(s), 4 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表