Excel精英培训网

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

[已解决]求助优化代码将I列单元格负数变为空

[复制链接]
发表于 2017-9-5 15:15 | 显示全部楼层 |阅读模式
本帖最后由 明日之星 于 2017-9-5 23:08 编辑

求助优化代码将I列单元格负数变为空.zip (15.34 KB, 下载次数: 5)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2017-9-5 16:30 | 显示全部楼层    本楼为最佳答案   
  1. Sub peitao()
  2. Dim i&, n
  3. n = 100000
  4. Range("i3:i" & Range("c65536").End(xlUp).Row).ClearContents
  5. For i = 3 To [c65536].End(3).Row
  6.   If n > Cells(i, 8) / Cells(i, 6) Then n = Cells(i, 8) / Cells(i, 6)
  7.   If Cells(i + 1, 2) <> "" Or i = [c65536].End(3).Row Then
  8.     Range(Cells(i, 9), Cells(i - Cells(i, 2).MergeArea.Count + 1, 9)).Merge
  9.     Cells(i, 9).MergeArea = Application.Max(0, n)
  10.     n = 100000
  11.   End If
  12. Next i
  13. End Sub
复制代码

评分

参与人数 1 +1 收起 理由
明日之星 + 1 很给力

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-20 12:31 , Processed in 0.389445 second(s), 14 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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