|
楼主 |
发表于 2019-1-8 14:39
|
显示全部楼层
Private Sub Worksheet_Change(ByVal Target As Range)
If Application.Intersect(Target, Range("C2:C65536")) Is Nothing Or Target.Count > 1 Then Exit Sub
Dim i&, st As Worksheet, Arr, d, n&
n = Target.Row
Set st = Sheets("数据data")
Set d = CreateObject("Scripting.Dictionary")
Arr = st.[b1].CurrentRegion
For i = 3 To UBound(Arr)
d(Arr(i, 1)) = i
Next
If d.exists(Target.Value) Then
i = d(Target.Value)
Target.Offset(0, -1).Value = Date '写入销售日期/写入编码
Target.Offset(0, 1) = Arr(i, 2) '写入入库名称
Target.Offset(0, 2) = Arr(i, 3) '写入规格型号
Target.Offset(0, 3) = Arr(i, 4) '写入类别
Target.Offset(0, -2) = "IQC1900" & Format(n - 1, "000")
Cells(n, 9).Formula = "=if(rc[-2]="""","""",rc[-1]/rc[-2])"
Cells(n, 12).Formula = "=if(rc[-4]="""","""",1-(rc[-1]+rc[-2])/rc[-4])"
End If
End Sub
老师,能否和这段代码融合在一起;或者是让红色这两段出来的值变为文本值(现在填入单元格的是公式)
|
|