ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 616|回复: 0

求助大神 看下导入清单代码出了什么问题

[复制链接]

TA的精华主题

TA的得分主题

发表于 2018-9-7 11:32 | 显示全部楼层 |阅读模式
本帖最后由 dhx1999526 于 2018-9-7 13:54 编辑

Sub setDefault()

Dim i As Integer
Dim default As String
Dim ads As String
Dim c As Integer

If Range("e13").Value = "" Then
    MsgBox "请选择要分析的包~"
Else

If Range("e14") = "" Then
    c = 1
Else
    Range("e13").Select
    Range(Selection, Selection.End(xlDown)).Select
    c = Selection.Rows.Count
End If

ads = "='step1-导入货物清单'!" & FillRng.Address()

Range("F13:F" & Trim(Str(12 + c))).Select

    With Selection.Validation
        .Delete
        .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
        xlBetween, Formula1:=ads
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = ""
        .ErrorTitle = ""
        .InputMessage = ""
        .ErrorMessage = ""
        .IMEMode = xlIMEModeNoControl
        .ShowInput = True
        .ShowError = True
    End With

    '调格式
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ThemeColor = 1
        .TintAndShade = -0.349986266670736
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ThemeColor = 1
        .TintAndShade = -0.349986266670736
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ThemeColor = 1
        .TintAndShade = -0.349986266670736
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ThemeColor = 1
        .TintAndShade = -0.349986266670736
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ThemeColor = 1
        .TintAndShade = -0.349986266670736
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ThemeColor = 1
        .TintAndShade = -0.349986266670736
        .Weight = xlThin
    End With

default = Worksheets(2).Range("m8").Value


    For i = 1 To c
        Range("F" & Trim(Str(i + 12))).Value = default
    Next

End If


End Sub

Sub text()

k = namedict.keys
t = namedict.items
For i = 0 To dict.Count - 1
    MsgBox k(i) & t(i)
Next







End Sub

Function ItemID() As String ' 获得以当前时间的数字组成的一串字符串 ' 用来给每个条目编号


Dim yy As Integer
Dim mm As Integer
Dim dd As Integer
Dim hh As Integer
Dim nn As Integer
Dim ss As Integer
Dim yue As String
Dim ri As String
Dim xiaoshi As String
Dim fenzhong As String
Dim miao As String

hh = Hour(Time)
nn = Minute(Time)
ss = Second(Time)

If hh = 0 Then
    xiaoshi = ""
Else
    xiaoshi = hh
End If



If nn < 10 Then
    fenzhong = "0" & nn
Else: fenzhong = nn
End If
If ss < 10 Then
miao = "0" & ss
Else: miao = ss
End If
ItemID = xiaoshi & fenzhong & miao '
Debug.Print ItemID
End Function



Public Sub searchStr()

Dim rng As Range
Dim str2 As Variant
Dim arr(6) As String
Dim c As Integer

arr(1) = "\"
arr(2) = "/"
arr(3) = "?"
arr(4) = "*"
arr(5) = "["
arr(6) = "]"

If Range("e14") = "" Then
    For a = 1 To 6
        i = InStr(Left(Range("c13").text, 7), arr(a))
        If i > 0 Then
            Range("c13").Font.Color = -16776961
            MsgBox "项目名称里包含非法字符“" & arr(a) & "”,请删除!"
            Range("c13").Font.Color = black
            Range("c13").Characters(Start:=i, Length:=1).Font.Color = -16776961
            Exit For
        Else
            Range("c13").Font.Color = black
        End If
    Next
Else
    Range("e13").Select
    Range(Selection, Selection.End(xlDown)).Select
    c = Selection.Rows.Count
    For Each rng In Range("c13:c" & Trim(Str(c + 12)))
        For a = 1 To 6
        i = InStr(Left(rng.text, 7), arr(a))
            If i > 0 Then
                rng.Font.Color = -16776961
                MsgBox "项目名称里包含非法字符“" & arr(a) & "”,请删除!"
                rng.Font.Color = black
                rng.Characters(Start:=i, Length:=1).Font.Color = -16776961
                Exit For
            Else
                rng.Font.Color = black
            End If
        Next
    Next
End If



End Sub
使用导入清单功能报错无效的过程调用或参数,跪谢大神!

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

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2025-1-13 15:45 , Processed in 0.022063 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

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