|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
如何让相同编码的内容,单价自动等于编码第1次出现对应单价单元格,并且产生公式连接。
比如A001,F12单元格=F$6单元格价格,其余同理
目前该功能可以得出相同单价,无法产生连接,现在需要能有链接,该如何调整
Sub 相同单价()
Dim MaxRow As Long: MaxRow = Cells(Rows.Count, 1).End(xlUp).Row
If MaxRow < 6 Then Exit Sub
Dim MyDis As Object: Set MyDis = CreateObject("Scripting.dictionary")
Dim MyFor As Long
For MyFor = 6 To MaxRow
If Not MyDis.exists(Cells(MyFor, 1).Value) Then
MyDis(Cells(MyFor, 1).Value) = MyFor
Else
Cells(MyFor, "F").Value = Cells(MyDis(Cells(MyFor, 1).Value), "F").Value
Cells(MyFor, "G").Value = Cells(MyDis(Cells(MyFor, 1).Value), "G").Value
Cells(MyFor, "H").Value = Cells(MyDis(Cells(MyFor, 1).Value), "H").Value
Cells(MyFor, "I").Value = Cells(MyDis(Cells(MyFor, 1).Value), "I").Value
' Cells(MyFor, "J").Value = Cells(MyDis(Cells(MyFor, 1).Value), "J").Value
' Cells(MyFor, "K").Value = Cells(MyDis(Cells(MyFor, 1).Value), "K").Value
' Cells(MyFor, "L").Value = Cells(MyDis(Cells(MyFor, 1).Value), "L").Value
' Cells(MyFor, "M").Value = Cells(MyDis(Cells(MyFor, 1).Value), "M").Value
' Cells(MyFor, "N").Value = Cells(MyDis(Cells(MyFor, 1).Value), "N").Value
End If
Next MyFor
MsgBox "OK"
End Sub
|
|