Excel精英培训网

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

[已解决]讨论:程序判断S列数据是否大于100这句 做不出判断

[复制链接]
发表于 2017-1-12 12:16 | 显示全部楼层 |阅读模式
本帖最后由 qiaodong64 于 2017-1-12 12:17 编辑

Sub test()                                                                                                                                                                                                     Dim mypath, myfile
mypath = ThisWorkbook.Path & "\"
myfile = Dir(mypath & "*.xlsx")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Do While myfile <> ""
If myfile <> ThisWorkbook.Name Then
Workbooks.Open mypath & myfile
With ActiveWorkbook_
     Dim i As Integer
     For i = 3 To 1000
      If Val(Cells(i, 19)) > 100 Then
         Value = "100"
         Exit For
      End If
     Next
End With
ActiveWorkbook.Save
ActiveWorkbook.Close
End If
myfile = Dir
Loop
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub




最佳答案
2017-1-12 12:28
本帖最后由 望帝春心 于 2017-1-12 12:51 编辑
  1. Sub test()
  2. Dim mypath, myfile
  3. mypath = ThisWorkbook.Path & ""
  4. myfile = Dir(mypath & "*.xlsx")
  5. Application.ScreenUpdating = False
  6. Application.DisplayAlerts = False
  7. Do While myfile <> ""
  8. If myfile <> ThisWorkbook.Name Then
  9. Workbooks.Open mypath & myfile
  10. With ActiveWorkbook_
  11.      Dim i As Integer
  12.      For i = 3 To 1000
  13.       If Val(Cells(i, 19)) > 100 Then
  14.          Cells(i, 19) = 100
  15.       End If
  16.      Next
  17. End With
  18. ActiveWorkbook.Save
  19. ActiveWorkbook.Close
  20. End If
  21. myfile = Dir
  22. Loop
  23. Application.DisplayAlerts = True
  24. Application.ScreenUpdating = True
  25. End Sub
复制代码

调试.zip

408.12 KB, 下载次数: 7

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2017-1-12 12:28 | 显示全部楼层    本楼为最佳答案   
本帖最后由 望帝春心 于 2017-1-12 12:51 编辑
  1. Sub test()
  2. Dim mypath, myfile
  3. mypath = ThisWorkbook.Path & ""
  4. myfile = Dir(mypath & "*.xlsx")
  5. Application.ScreenUpdating = False
  6. Application.DisplayAlerts = False
  7. Do While myfile <> ""
  8. If myfile <> ThisWorkbook.Name Then
  9. Workbooks.Open mypath & myfile
  10. With ActiveWorkbook_
  11.      Dim i As Integer
  12.      For i = 3 To 1000
  13.       If Val(Cells(i, 19)) > 100 Then
  14.          Cells(i, 19) = 100
  15.       End If
  16.      Next
  17. End With
  18. ActiveWorkbook.Save
  19. ActiveWorkbook.Close
  20. End If
  21. myfile = Dir
  22. Loop
  23. Application.DisplayAlerts = True
  24. Application.ScreenUpdating = True
  25. End Sub
复制代码
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-24 13:38 , Processed in 0.248103 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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