打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
如果找到N / A,VBA excel代码删除行(VBA excel code to delete ...

如果找到N / A,VBA excel代码删除行(VBA excel code to delete the rows if N/A is found)

我正在寻找一种方法来找到整列中的N/A单元格,然后如果找到N/A则删除整行。 我找到了这个VBA代码,但它对我不起作用,因为它只选择一列。 请帮忙(我在Excel Mac 2011中处理大约300000行)

Sub DeleteBlankARows() 
    With Application 
        .Calculation = xlCalculationManual 
        .ScreenUpdating = False 
        Dim r As Long 
        For r = Cells(Rows.Count, 11).End(xlUp).Row To 1 Step -1 
            If Cells(r, 11) = '' Then Rows(r).Delete 
        Next r 
        .Calculation = xlCalculationAutomatic 
        .ScreenUpdating = True 
    End With 
End Sub 

I am looking for a way to find the N/A cells in the entire columns and then delete the entire row if N/A is found. I found this VBA code, but it just doesn't work for me because it selects only one column. Please help (I am working on around 300000 rows in Excel Mac 2011)

Sub DeleteBlankARows() With Application .Calculation = xlCalculationManual .ScreenUpdating = False Dim r As Long For r = Cells(Rows.Count, 11).End(xlUp).Row To 1 Step -1 If Cells(r, 11) = '' Then Rows(r).Delete Next r .Calculation = xlCalculationAutomatic .ScreenUpdating = True End With End Sub

原文:https://stackoverflow.com/questions/10612072
2021-09-06 16:09

满意答案

试试这个(在Windows XP / Excel 2007上测试但它应该适用于Mac / Office 2011):

Option Explicit Sub DeleteNARows() Dim r As Long Dim iCol As Long With Application .Calculation = xlCalculationManual .ScreenUpdating = False .DisplayAlerts = False For iCol = 1 To Cells(1, Columns.Count).End(xlToLeft).Column For r = Cells(Rows.Count, iCol).End(xlUp).Row To 1 Step -1 If Application.WorksheetFunction.IsNA(Cells(r, iCol)) Then Rows(r).Delete Next r Next iCol .Calculation = xlCalculationAutomatic .ScreenUpdating = True .DisplayAlerts = True End With End Sub

请注意,您可以(并且可能必须)更改要在代码开头检查#N #N/A的列


Try this (tested on Windows XP / Excel 2007 but it should work on Mac / Office 2011):

Option Explicit

Sub DeleteNARows()
    Dim r As Long
    Dim iCol As Long
    With Application
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
        .DisplayAlerts = False
        For iCol = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
            For r = Cells(Rows.Count, iCol).End(xlUp).Row To 1 Step -1
                If Application.WorksheetFunction.IsNA(Cells(r, iCol)) Then Rows(r).Delete
            Next r
        Next iCol
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
        .DisplayAlerts = True
    End With
End Sub

Note that you can (and probably have to) change the column where you want to check fot #N/A at the begining of the code

相关问答

更多

如果找到N / A,VBA excel代码删除行(VBA excel code to delete the rows if N/A is found)

试试这个(在Windows XP / Excel 2007上测试但它应该适用于Mac / Office 2011): Option Explicit Sub DeleteNARows() Dim r As Long Dim iCol As Long With Application .Calculation = xlCalculationManual .ScreenUpdating = False .DisplayAlert...

Excel VBA删除行(Excel VBA Delete Rows)

这是删除行时的常见问题。 想象一下,您正在逐行移动一行for循环并删除: For cnt = 7 To dlt Rows(cnt).EntireRow.Delete cnt = cnt + 1 Next 你在第7行,你删除它。 这会将所有行向上移动。 第8行现在是第7行。然后你将你的cnt变量增加1(到8)并删除第8行。但你错过了第7行,这是第8行......这是疯狂的香蕉。 相反,将for循环更改为向后工作: For cnt = dlt to 7 step -1 Ro...

VBA删除Excel上给定范围内的空白行[复制](VBA Delete blank rows in a given range on Excel [duplicate])

您需要从范围的末尾向后循环并删除相关的行索引,如下所示 for x=numrows to 1 step -1 if ws.range('a' & x).value='' then ws.rows(x).delete next x 其中ws是您正在处理的工作表。 You need to loop backwards from the end of the range and delete the relevant row index, like so for x=numrows to 1...

在Excel VBA中删除表名(Delete table name in Excel VBA)

您可以从表中备份数据,删除表并还原数据。 Sub test() Dim rng As Range Dim rngVals As Variant Set rng = YourSheet.ListObjects('Table2').Range rngVals = rng.Value YourSheet.ListObjects('Table2').Delete rng.Value = rngVals Set rng = Nothing En...

Excel VBA:如果单元格不包含表中的值,则删除行(Excel VBA: delete rows if cells do not contain values from a table)

干得好: Sub Remove_Rows() Dim i As Long i = Range('C' & Cells.Rows.Count).End(xlUp).Row ' Find the bottom row number Do Until i = 1 ' This loops to the top row before stopping (assuming you have a header row that you want to keep) If WorksheetFunct...

删除vba excel中的行,但只删除备用行[复制](Deleting rows in vba excel, but only alternate rows being deleted [duplicate])

删除行时,您必须认识到您正在删除正在循环的相同行。 我的建议是从最后一行开始,使用-1循环计数器进行迭代。 这样,您可以安全地删除一行而不影响剩余的行。 换句话说 - 从lastRow向后迭代到2(或者你的起始行是什么)。 When deleting rows, you have to realize that you're deleting the same rows that you're looping through. My suggestion is to start from the ...

在VBA的excel中删除每n行(delete every n rows in excel with VBA)

Powerquery(2016,在数据选项卡>获取和变换,2013免费加载项从微软然后powerquery选项卡) 绝对是针对您提到的行数的这种操作进行了优化。 编写查询需要1分钟时间。 .66 of a second on a test with 200K rows to complete task. 1)选择数据中的行,然后从表中选择数据> 2)指出你的表是否有标题 3)查询编辑器屏幕弹出 4)选择主页>删除行>删除备用行 5)指定模式。 例如,保持1删除3在你的例子中: 6)点击确定。 遵...

如何使用excel VBA删除第一列中包含特定代码的行?(How to delete a row that contains a certain code in the first column using excel VBA?)

根据你的叙述(“我必须......删除一行”)你似乎只打扰了一句“CFS-GHOST-DJKT” 在这种情况下,不需要迭代单元格,只需尝试找到它,如果成功,则删除整行 Dim f As Range Set f = Range('A7', Cells(Rows.Count, 'A').End(xlUp)).Find(what:='CFS-GHOST-DJKT', LookIn:=xlValues, lookat:=xlPart) If Not f Is Nothing Th...

Excel VBA:确定找到值的行(Excel VBA: determing rows on which the value is found)

我更喜欢MATCH来查找单列搜索: Set rep = Sheets('Details') Dim test As Long For i = 2 To n test = 0 On Error Resume Next test = Application.WorksheetFunction.Match(Worksheets('Work_report').Range('E' & i).Value, Sheets('Work').Range('A:A'), 0) On E...

删除文件夹VBA中的非Excel文件(Delete non-Excel Files in a folder VBA)

使用以下应该按要求。 注意,最好使用Like运算符来比较部分字符串,在这种情况下, Not运算符只搜索那些不匹配的字符串。 strFileName = Dir('C:\test\*') Do While strFileName <> '' If Not lcase$(strFileName) Like '*.xls' Then 'or .txt or .csv or whatever Kill 'C:\test\' & strFileName End If strFileNa...

相关文章

更多

原创:如何实现在Excel通过循环语句设置指定行的格式

原创:如何实现在Excel通过循环语句设置指定行的格式 一、需求: 想让excel的某些行(比如3的倍 ...

reading notes for solr source code

solr source code 1 org.apache.solr.common 基本的类对象 ...

HttpClient DELETE请求示例

本教程演示如何使用Apache HttpClient 4.5创建Http DELETE请求。 HTTP ...

[转]So You Want To Be A Producer

pro-du-cer n. 1. Someone from a game publisher who ...

JXLS根据excel模板生成EXCEL并下载

JXLS根据excel模板生成EXCEL并下载,jxl.jar,jxls-core-0.9.9.jar ...

English,The Da Vinci Code,Chapter 1-3

CHAPTER 1 http://readanybooks.net/thrillers/TheDaVi ...

solr delete query

Solr1.4 Both delete by id and delete by query can b ...

POI 操作Excel公式

在执行这个公式

这种的EXCEL表格 怎么来解析??

如图的EXCEL表格 怎么来解析??

Becoming a data scientist

Data Week: Becoming a data scientist Data Pointed, ...

最新问答

更多

Microsoft Cognitive API可以在本地云中使用吗?(Can Microsoft Cognitive APIs be used in local cloud)

简短的回答是不可能的。 目前没有本地部署支持。 并没有具体的计划来支持这一点。 A short answer is not possible. Current there is no local deployment support. And there is no specific plan to support that too.

用事件调度线程构造GUI并进行赋值(construct GUI with event dispatch thread and make assignment)

对于那些有一天应该对这个问题感兴趣的人来说,这就是解决方案:我犯了一个错误。 实际上,您应该区分构建GUI对象并使其可见。 所以这是这样做的方法: public class MainClass { final GUIClass gui = new GUIClass(); Runnable r = new Runnable() { public void run() {

链接到MonoTouch中的C ++本机库(Linking to a C++ native library in MonoTouch)

你当然可以使用C ++ api,但你需要将其包装在C api或ObjC + btouch api中才能与之交谈。 调用C api使用PInvoke,而C ++库使用符号修改。 虽然从理论上讲你可能会破坏错位符号,但这不是一个好主意,因为修改是编译器特定的。 You can certainly use a C++ api, but you will need to either wrap it in a C api, or a ObjC+btouch api to be able to talk

怎样找到mysql驱动

在百度里搜“mysql jdbc驱动下载”,注意找和你mysql版本一致的下,不是越新越好

角ui路由器 - 如何访问嵌套的,命名视图中的参数,从父模板传递?(Angular ui-router - how to access parameters in nested, named view, passed from the parent template?)

instanceID被声明为一个参数,所以我们可以这样访问它 .controller('ViewWorklogCrtl', [ '$scope','$stateParams' function($scope , $stateParams ) { // $scope.instanceID = $stateParams.instanceID; ... 所有其他细节可以在这里找到https://github.com

Subclipse错误消息“存储库的预期格式'3';(Subclipse error message “Expected format '3' of repository; found format '5'”)

我对你发布的问题无能为力,但我建议尝试颠覆。 我对一些subclipse错误感到沮丧,并且更加快乐。 安装需要更多的工作。 Eclipse颠覆项目 I can't help on your posted problem, but I would recommend trying subversive instead. I made the switch out of frustration with some subclipse bugs and have been much happier.

如何将Java 8 Stream转换为二维数组?(How to convert a Java 8 Stream into a two dimensional array?)

如果您查看 A[] toArray(IntFunction generator) ,您会看到它将Stream转换为A[] ,这是A元素的一维数组。 因此,为了创建2D数组, Stream的元素必须是数组。 因此,如果首先将Stream的元素map到1D数组,然后调用toArray ,则可以创建2D数组: Float[][] floatArray = map.entrySet() .stream() .map(key -> new Flo

在ng-class中表达表达式方法(Delegate method in expression in ng-class)

您在代码段中的语法是正确的: ng-class='{'redDiv': mc.delegateCheckStatus(mc.STATES.down, machine.status), ...} 问题似乎存在于delegateCheckStatus函数本身。 The syntax you have in the snippet is correct: ng-class='{'redDiv': mc.delegateCheckStatus(mc.STATES.down, machine.statu

那位朋友帮忙翻译成英文,附中文资料,毕业设计用

Discharge pulley 卸料滚筒 Take-up pulley 拉紧滚筒 Bend pulley 改向滚筒 Discharge snub pulley 卸料增面滚筒 Housings 轴承座 Sealing type 密封类型 Flow deviation system 分离系统 Tripper 卸料机 Movable head 活动头 Deviation flow car 卸料车 Pneumatic cylinder 气缸 Hydraulic cylinder 液压缸 Actuato
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Excel | VBA——合并工作簿与合并工作表
各种Excel VBA的命令大全(4)
Excel中用VBA实现删除空行和空列
Excel | VBA轻松实现跨多工作表查询数据
Word VBA技术:删除表格中内容相同的重复行
Excel Quick Tips: How To Flip Cells & Switch Rows or Columns
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服