Excel精英培训网

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

求帮忙修改VBA代码

[复制链接]
发表于 2014-7-9 08:55 | 显示全部楼层 |阅读模式
代码如下:
Sub xxx()
Application.Calculation = xlCalculationManual
Sheets("数据提取").Range("C2:L10000").ClearContents
Dim i As Worksheet
  For Each i In ThisWorkbook.Sheets
   If i.Name <> "中2库存" Or i.Name <> "开工系统数" Or i.Name <> "开工对比" Then
    lr = i.Cells(65536, 3).End(xlUp).Row
      For j = 5 To lr
        If i.Cells(j, "N") <> "√" Then  'M列
         b = Sheets("数据提取").Cells(65536, 3).End(xlUp).Row + 1
         i.Range("C" & j & ":L" & j).Copy Sheets("数据提取").Cells(b, "C")     'C:L列
         Sheets("数据提取").Cells(b, "A") = i.Range("C1")
        End If
      Next
     End If
   Next
   Application.Calculation = xlCalculationAutomatic
End Sub

这个代码已经指定不运行的表格了,但在运行代码时,依然会将整个工作薄都处理,是不是那里不对,帮忙看看?



008.rar

218.59 KB, 下载次数: 4

发表于 2014-7-9 11:40 | 显示全部楼层
你的附件中没有下面这句代码提到的表名
If i.Name <> "中2库存" Or i.Name <> "开工系统数" Or i.Name <> "开工对比" Then
回复

使用道具 举报

发表于 2014-7-9 12:13 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2014-7-9 13:37 | 显示全部楼层
su45 发表于 2014-7-9 12:13
你可以把 Or 改为 And 试试!

换成And真的可以了,如果我想清除读取后的数据,应该怎样改。或者是清除B1:L100?
回复

使用道具 举报

发表于 2014-7-9 15:26 | 显示全部楼层
Range("B1:L100").ClearContents
回复

使用道具 举报

发表于 2014-7-9 16:25 | 显示全部楼层
  If i.Name = "中2库存" Or i.Name = "开工系统数" Or i.Name = "开工对比" Then
Else
你的代码
End If
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-6 11:56 , Processed in 0.287764 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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