软件:EXCEL
版本:2013
各位版大好~
我写了一个销货单汇入清单的VB
奇怪的是
我从编译器内案执行一切顺利
但是在表单建立按钮连接VBA程式后
一直出现执行错误:型态不符合
重点是我用msgbox回变量型态都是double
第一次遇到这样
不知道有没有人知道什么
http://imgur.com/a/D1IU7
http://imgur.com/a/D1IU7
感谢
原档案 https://drive.google.com/file/d/0B5FM7x4Wx7AjcGhvWEJDSGFQT1k/view?usp=sharing
原文如下
Public Sub 汇入清单()
Application.ScreenUpdating = False
Dim r, m, i As Integer
r = Sheets("清单").Cells(66666, 2).End(xlUp).Row
m = WorksheetFunction.CountA(Sheets("销货单").Range("B6:B17")) + 1
'填入对应数量
With Sheets("清单")
.Unprotect
.Range(.Cells(r + 1, 1), .Cells(r + m, 1)) = Range("G1").Value - 1
.Range(.Cells(r + 1, 2), .Cells(r + m, 2)) = Range("C1")
.Range(.Cells(r + 1, 3), .Cells(r + m, 3)) = Range("C2")
.Range(.Cells(r + 1, 4), .Cells(r + m, 4)) = Range("C3")
Range(Cells(6, 2), Cells(6 + m - 2, 7)).Copy
.Range(.Cells(r + 1, 5), .Cells(r + m - 3, 10)).PasteSpecial
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
.Cells(r + m, 5) = "折让"
On Error GoTo XX
.Cells(r + m, 9).Value = -Cells(3, 7)
XX: MsgBox TypeName(.Cells(r + m, 9).Value) & TypeName(-Cells(3, 7))
.Cells(r + m, 11) = Cells(2, 7)
With .Range(.Cells(r + m, 1), .Cells(r + m, 11)).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'.EnableSelection = xlNoSelection
End With
Application.ScreenUpdating = True
End Sub