Sub-Parent_Name((
'Formula to update Parent Name from column 1
将ws标注为工作表
设置ws=ThisWorkbook。片材("DB"(
Sheets("DB").Select
last_row = Cells(Rows.Count, 1).End(xlUp).Row
Range("Y2").Select
ActiveCell.Formula = "=VLOOKUP(X2,'ML DB'!C:G,5,0)"
ActiveCell.AutoFill Destination:=Range(ActiveCell.Address & ":Y" & last_row)
Columns("Y:Y").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Replace #N/A with ##
Columns("Y:Y").Select
Selection.Replace What:="#N/A", Replacement:="##", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Range("Y1").Select
片材("DB"(。选择
last_row=单元格(Rows.Count,1(。结束(xlUp(。行
For iRow = 2 To last_row
If Range("Y" & iRow).Value = "##" Then
通过按钮点击时,此行出现错误(运行时错误1004,应用程序定义或对象定义错误(
ws.Range("Y" & iRow).Formula = Replace(Range("Y" & iRow), "##", "=VLOOKUP(X" & iRow & ",'ML DB'!D:G,4,0")
End If
Next iRow
Columns("Y:Y").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Replace #N/A with ##
Columns("Y:Y").Select
Selection.Replace What:="#N/A", Replacement:="##", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
范围("Y1"(。选择
结束子
也许可以再添加一些&
ws.Range("Y" & iRow).Formula = Replace(Range("Y" & iRow & ), "##", "=VLOOKUP(X" & iRow & ",'ML DB'!D:G,4,0")