|
本帖最后由 百读谷歌 于 2024-9-11 14:15 编辑
求助大佬,原本代码是输入数字后匹配B表R列后填充N列内容的,
现在我想填充N列内容同时也把B表的P列的的格式复制过来到输入单元格对应的E列位置。(注意只是复制格式,内容不要复制)
我尝试过修改代码,但是复制格式这里始终没反应。
求助大佬给看看,怎么添加下代码实现这个需求?感谢!!
原代码
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ar, i&, dic As Object
If Target.Count > 1 Then Exit Sub
If Target.Column = 2 And Target.Row > 1 Then
Set dic = CreateObject("Scripting.Dictionary")
Application.EnableEvents = False
With Sheets(2)
ar = .Range("N1", .Cells(Rows.Count, "R").End(xlUp))
For i = 2 To UBound(ar)
If Len(ar(i, 5)) Then dic(ar(i, 5)) = ar(i, 1)
Next i
If dic.exists(Target.Value) Then Target.Value = dic(Target.Value)
End With
Application.EnableEvents = True
End If
End Sub
|
|