|
本帖最后由 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
使用导入清单功能报错无效的过程调用或参数,跪谢大神!
|
|