Excel精英培训网

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

[已解决]按条件删除数据

[复制链接]
发表于 2016-6-21 16:16 | 显示全部楼层 |阅读模式
新建 Microsoft Excel 工作表.zip (5.15 KB, 下载次数: 17)
发表于 2016-6-21 16:26 | 显示全部楼层    本楼为最佳答案   
代码如下:
  1. Sub xx()
  2.     Dim arr, n&, i&, x&, y&
  3.     With Sheet1
  4.         n = .Cells(.Rows.Count, 2).End(xlUp).Row
  5.         arr = .Range("B1:B" & n)
  6.         For i = 1 To n
  7.             If arr(i, 1) = "序号" Then x = i
  8.             If arr(i, 1) = "合计" Then
  9.                 y = i
  10.                 Exit For
  11.             End If
  12.         Next
  13.         .Rows(x + 1 & ":" & y - 1).Delete
  14.     End With
  15. End Sub
复制代码
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-26 19:51 , Processed in 0.302447 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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