Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
12
返回列表 发新帖
楼主: huangxuejin

[已解决]单元格格式自定义后还是按原来数字计算

[复制链接]
发表于 2016-10-21 15:49 | 显示全部楼层
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
回复

使用道具 举报

 楼主| 发表于 2016-10-21 16:55 | 显示全部楼层
感谢砂海提示,现在完全完善所需的要求,谢谢谢谢

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count = 1 Then
        If Target.Column = 3 Or Target.Column = 7 Then '3表示3列、7表示7列
            If Target.Value <= 24 Then
                If Target.Value > 12 Then
                    Target.NumberFormatLocal = Application.Substitute(Target.Value - 12, "0", "!0") & ""
                     Else
                    Target.NumberFormatLocal = "G/通用格式"   '12以下 都是显示常规
                End If
            End If
        End If
    End If
End Sub
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-3 10:07 , Processed in 0.288214 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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