该加载项在我的计算机上时可以使用,但是一旦我通过电子邮件将加载项文件和启用了宏的文件都发送出去,则该加载项将不再起作用,并且无法同时打开两个相同名称的文件。不明白为什么他会收到此错误消息。我朋友计算机上的插件似乎加载了带有VBA的工作表,但是我的计算机上却没有,这可能是问题所在,为什么会这样做?
对于上下文,这是一个宏,它过滤帐户并突出显示某些字段。我加载了每天发送的excel文件,因此我想在快速访问工具栏中添加一个按钮来运行宏。
我的流程是我同时通过电子邮件发送了这两个文件。然后将它们保存到他的计算机中。向开发人员提供excel加载项,找到文件,添加文件,然后将其分配给快速访问工具栏。我错过了什么吗?
For Each ws In Worksheets
If ws.Name = "modified_report" Then
Application.DisplayAlerts = False
Sheets("modified_report").Delete
Application.DisplayAlerts = True
End If
Next
End Sub
'Copying sheet
Sub copy_sheet()
Sheets("fed_instr_extract_revised").Select
Excel.ActiveSheet.Copy After:=Excel.Sheets("fed_instr_extract_revised")
'Rename new copied sheet
Excel.ActiveSheet.Name = "modified_report"
End Sub
'filtering equity accounts
Sub filter_equity()
Set ws = Worksheets("modified_report")
Application.ScreenUpdating = False
Sheets("modified_report").Select
'Selecting the equity accounts
Selection.AutoFilter
Worksheets("modified_report").Range("$A$1:$A$2000").AutoFilter Field:=1, Criteria1:=Array( _
"106", "123", "323", "217", "290", "291", "390", "590", "790", "792", "793", "890"), Operator:=xlFilterValues
End Sub
'deleting equity accounts
Sub delete_equity()
Dim sh As Worksheet, rng As Range, LstRw As Long
'deleting the autofiltered equity accounts
Set sh = Sheets("modified_report")
With sh
LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row
Set rng = .Range("A2:A" & LstRw).SpecialCells(xlCellTypeVisible)
rng.EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
'selecting previous accounts
Sub filter_by_acr()
Set ws = Worksheets("modified_report")
Application.ScreenUpdating = False
strInput = InputBox("Enter acronym to filter on")
Worksheets("modified_report").Range("A1").AutoFilter Field:=6, Criteria1:=strInput
End Sub
'deleting filter accounts
Sub delete_filtered_acr()
Dim sh As Worksheet, rng As Range, LstRw As Long
Set sh = Sheets("modified_report")
With sh
LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row
Set rng = .Range("A2:A" & LstRw).SpecialCells(xlCellTypeVisible)
rng.EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
'filter for everything but the accounts from this month
Sub filtering_older_than_one_month()
Dim sh As Worksheet, rng As Range, LstRw As Long
Set sh = Sheets("modified_report")
Selection.AutoFilter
Worksheets("modified_report").Range("$A$1:$A$2000").AutoFilter Field:=18, Criteria1:="<" & CLng(Date - 3)
End Sub
'deleting 1 month old accounts
Sub delete_filtered_date()
Dim sh As Worksheet, rng As Range, LstRw As Long
Set sh = Sheets("modified_report")
With sh
LstRw = .Cells(.Rows.Count, "A").End(xlUp).Row
Set rng = .Range("A2:A" & LstRw).SpecialCells(xlCellTypeVisible)
rng.EntireRow.Delete
.AutoFilterMode = False
End With
End Sub
'highlighting
Sub highlight()
Dim myRange As Range, cel As Range
Set myRange = Sheets("modified_report").Range("K:M")
n = Sheets("modified_report").Range("K" & Sheets("modified_report").Rows.Count).End(xlUp).Row
For Each cel In myRange
If cel.Row > n Then Exit For
If Trim(cel.Value) = "" Then cel.Interior.ColorIndex = 6
Next cel
End Sub
'sort highlighted
Sub sort_highlighted()
Cells.Select
ActiveWorkbook.Worksheets("modified_report").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("modified_report").Sort.SortFields.Add2 Key:=Range( _
"K2:K255"), SortOn:=xlSortOnCellColor, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("modified_report").Sort.SortFields.Add2 Key:=Range( _
"L2:L255"), SortOn:=xlSortOnCellColor, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("modified_report").Sort.SortFields.Add2 Key:=Range( _
"M2:M255"), SortOn:=xlSortOnCellColor, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("modified_report").Sort
.SetRange Range("A1:Q255")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
该宏的运行方式与我的计算机上的运行方式相同。