Excel精英培训网

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

[已解决]判断字典里是否有要的内容

[复制链接]
发表于 2013-6-10 11:50 | 显示全部楼层 |阅读模式
如果日报表A列里的内容有字典里没有的,把没有的那个单元格填充红色,并弹出消息“字段溢出”
最佳答案
2013-6-10 12:37
If d.exists(wbk.Sheets(1).Cells(i, 1).Value) Then
                    .Cells(d(wbk.Sheets(1).Cells(i, 1).Value), j + 3) = wbk.Sheets(1).Cells(i, 3)
                Else
                    MsgBox wbk.Name & "的单元格" & wbk.Sheets(1).Cells(i, 1).Address & ",字段" & wbk.Sheets(1).Cells(i, 1) & "溢出"
                End If

111.rar

29.65 KB, 下载次数: 7

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2013-6-10 12:00 | 显示全部楼层

.Cells(d(wbk.Sheets(1).Cells(i, 1).Value), j + 3) = wbk.Sheets(1).Cells(i, 3)

改成
  1. If d.exists(wbk.Sheets(1).Cells(i, 1).Value) Then
  2.             .Cells(d(wbk.Sheets(1).Cells(i, 1).Value), j + 3) = wbk.Sheets(1).Cells(i, 3)
  3. Else
  4.             MsgBox "字段溢出"
  5. End If
复制代码
回复

使用道具 举报

 楼主| 发表于 2013-6-10 12:25 | 显示全部楼层
1032446692 发表于 2013-6-10 12:00

.Cells(d(wbk.Sheets(1).Cells(i, 1).Value), j + 3) = wbk.Sheets(1).Cells(i, 3)

如果内容多的话找起来会很麻烦,能不能在消息框里把那个字典里没有的内容也一起显示出来
回复

使用道具 举报

发表于 2013-6-10 12:37 | 显示全部楼层    本楼为最佳答案   
If d.exists(wbk.Sheets(1).Cells(i, 1).Value) Then
                    .Cells(d(wbk.Sheets(1).Cells(i, 1).Value), j + 3) = wbk.Sheets(1).Cells(i, 3)
                Else
                    MsgBox wbk.Name & "的单元格" & wbk.Sheets(1).Cells(i, 1).Address & ",字段" & wbk.Sheets(1).Cells(i, 1) & "溢出"
                End If
回复

使用道具 举报

 楼主| 发表于 2013-6-10 12:37 | 显示全部楼层
问题已解决,得到了蓝桥玄霜版主的帮助。
回复

使用道具 举报

发表于 2013-6-10 12:56 | 显示全部楼层
fengdavid 发表于 2013-6-10 12:37
问题已解决,得到了蓝桥玄霜版主的帮助。

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-4 22:41 , Processed in 0.436502 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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