Xóa Name rác.

Liên hệ QC

File đính kèm

  • Book1.xls
    142.5 KB · Đọc: 1
em tìm được đoạn code này để xoá name ẩn trong file nhưng khi tìm thấy name ẩn phải click "yes" để xác nhận xoá name, nhờ các anh chị sửa code giúp em để tự động xoá name ẩn mà không cần click "yes" để xác nhận xoá từng name không ạ. cảm ơn các anh chị nhiều.



Sub Remove_Hidden_Names()

' Dimension variables.
Dim xName As Variant
Dim Result As Variant
Dim Vis As Variant

' Loop once for each name in the workbook.
For Each xName In ActiveWorkbook.Names

'If a name is not visible (it is hidden)...
If xName.Visible = True Then
Vis = "Visible"
Else
Vis = "Hidden"
End If

' ...ask whether or not to delete the name.
Result = MsgBox(prompt:="Delete " & Vis & " Name " & _
Chr(10) & xName.Name & "?" & Chr(10) & _
"Which refers to: " & Chr(10) & xName.RefersTo, _
Buttons:=vbYesNo)

' If the result is true, then delete the name.
If Result = vbYes Then xName.Delete

' Loop to the next name.
Next xName

End Sub
 
em tìm được đoạn code này để xoá name ẩn trong file nhưng khi tìm thấy name ẩn phải click "yes" để xác nhận xoá name, nhờ các anh chị sửa code giúp em để tự động xoá name ẩn mà không cần click "yes" để xác nhận xoá từng name không ạ. cảm ơn các anh chị nhiều.
Sub Remove_Hidden_Names()
' Dimension variables.
Dim xName As Variant
Dim Result As Variant
Dim Vis As Variant
' Loop once for each name in the workbook.
For Each xName In ActiveWorkbook.Names
'If a name is not visible (it is hidden)...
If xName.Visible = True Then
Vis = "Visible"
Else
Vis = "Hidden"
End If

' ...ask whether or not to delete the name.
Result = MsgBox(prompt:="Delete " & Vis & " Name " & _
Chr(10) & xName.Name & "?" & Chr(10) & _
"Which refers to: " & Chr(10) & xName.RefersTo, _
Buttons:=vbYesNo)

' If the result is true, then delete the name.
If Result = vbYes Then
xName.Delete

' Loop to the next name.
Next xName
End Sub
Bạn thử xóa đoạn bôi đỏ xem sao.
 
Lần chỉnh sửa cuối:
Web KT
Back
Top Bottom