Excel精英培训网

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

包含字符串计算很慢

[复制链接]
发表于 2022-6-28 18:05 | 显示全部楼层 |阅读模式
Sub 材料计算()
Dim i%
    For i = 4 To 938
        If Cells(i, 3) Like "*269M*" Then
            Cells(i, 7) = Cells(i, 6) * 85.54 + Cells(i, 4) * 22.5
        ElseIf Cells(i, 3) Like "*1603*" Then
            Cells(i, 7) = Cells(i, 6) * 80.34
        ElseIf Cells(i, 3) Like "*PB2*" Then
            Cells(i, 7) = Cells(i, 6) * 113.91 + Cells(i, 4) * 22.5
        ElseIf Cells(i, 3) Like "*R111*" Then
            Cells(i, 7) = Cells(i, 6) * 105.18 + Cells(i, 4) * 21.5
        ElseIf Cells(i, 3) Like "*1108*" Then
            Cells(i, 7) = Cells(i, 6) * 80.67
        ElseIf Cells(i, 3) Like "*477*" Or Cells(i, 3) Like "*21103*" Or Cells(i, 3) Like "*0659H" Then
            Cells(i, 7) = Cells(i, 6) * 91.08
        Else
            Cells(i, 7) = Cells(i, 6) * 49.30558
        End If
    Next i
End Sub

发表于 2022-6-29 10:40 | 显示全部楼层
回复

使用道具 举报

发表于 2022-6-29 10:41 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2022-6-29 11:27 | 显示全部楼层
limonet 发表于 2022-6-29 10:41
用Select Case,肯定快了。

怎样写
回复

使用道具 举报

发表于 2022-6-29 14:24 | 显示全部楼层
没有附件无法测试。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-24 17:44 , Processed in 0.371474 second(s), 9 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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