Excel精英培训网

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

[已解决][求助]单元格输入数据后触发事件的代码

[复制链接]
发表于 2011-1-10 13:26 | 显示全部楼层 |阅读模式
对单元格D1输入数据后触发事件的代码?
比如:在D1单元格输入100后自动变成100T
如果在对这个时间添加一个范围又该怎么写?
比如在D1:E3输入数据,数据自动变换,在其他单元格输入不变换
最佳答案
2011-1-10 14:08
  1. Private Sub Worksheet_Change(ByVal Target As Range)

  2. If Not Intersect(Range("d1:e3"), Target) Is Nothing Then
  3.     Application.EnableEvents = False
  4.    
  5.         Target.Value = Target.Value & "T"
  6.     Application.EnableEvents = True
  7. End If



  8. End Sub
复制代码
发表于 2011-1-10 13:54 | 显示全部楼层
对你的要求进行详细说明并上传附件。
回复

使用道具 举报

发表于 2011-1-10 14:08 | 显示全部楼层    本楼为最佳答案   
  1. Private Sub Worksheet_Change(ByVal Target As Range)

  2. If Not Intersect(Range("d1:e3"), Target) Is Nothing Then
  3.     Application.EnableEvents = False
  4.    
  5.         Target.Value = Target.Value & "T"
  6.     Application.EnableEvents = True
  7. End If



  8. End Sub
复制代码
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-25 16:24 , Processed in 0.242626 second(s), 7 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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