Excel精英培训网

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

[已解决]如何用数据有效性,限制性填写数据。

[复制链接]
发表于 2017-1-10 19:10 | 显示全部楼层 |阅读模式
各位大侠好:
      我们工作中经常采购东西,一般情况下,相同的东西单价应该相同,请问,如何用数据有效性,限制性填写商品的单价。
  具体情况及要求,请看我上传的附件,谢谢指点。
最佳答案
2017-1-11 15:00
    For Each wks In ActiveWorkbook.Worksheets
        If wks.Name <> "目录" Then
            With wks.Cells
                Set rCell = .Find(what:="*AC", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchByte:=True, MatchCase:=False, SearchFormat:=False)
                If Not rCell Is Nothing Then
                    szFirst = rCell.Address
                    Do
                        rCell.Offset(qh, ql) = "  数字  "   
                        Set rCell = .FindNext(rCell)
                        i = i + 1
                        Loop While Not rCell Is Nothing And rCell.Address <> szFirst
                    End If
                End With
            End If
        Next wks
这是我用的一段代码,你自己改一下

表格.rar

7.16 KB, 下载次数: 15

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
 楼主| 发表于 2017-1-11 09:18 | 显示全部楼层
回复

使用道具 举报

发表于 2017-1-11 14:47 | 显示全部楼层
回复

使用道具 举报

发表于 2017-1-11 15:00 | 显示全部楼层    本楼为最佳答案   
    For Each wks In ActiveWorkbook.Worksheets
        If wks.Name <> "目录" Then
            With wks.Cells
                Set rCell = .Find(what:="*AC", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchByte:=True, MatchCase:=False, SearchFormat:=False)
                If Not rCell Is Nothing Then
                    szFirst = rCell.Address
                    Do
                        rCell.Offset(qh, ql) = "  数字  "   
                        Set rCell = .FindNext(rCell)
                        i = i + 1
                        Loop While Not rCell Is Nothing And rCell.Address <> szFirst
                    End If
                End With
            End If
        Next wks
这是我用的一段代码,你自己改一下
回复

使用道具 举报

 楼主| 发表于 2017-3-29 17:38 | 显示全部楼层
谢谢,就是有点复杂。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-19 11:39 , Processed in 0.256003 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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