sách gpt4 ai đã đi

excel - 如何将所有这些代码放在一起以作为一个模块运行?

In lại 作者:行者123 更新时间:2023-12-04 21:42:40 27 4
mua khóa gpt4 Nike

这个问题可能看起来很傻,但我以前从未尝试过。
您如何将这些不同的代码作为单个模块工作?
我在我的工作表中添加了一个按钮,希望它能一次处理所有不同的请求。
工作表名称:WC
第一 : ReplaceVlookupValues() 用于用值替换 vlookups,以便宏可以拾取它。
第二 : Sub DeleteStatus() 用于删除列中的选定单词H .
第三 : DeleteEmployeeCriteria() 用于删除列 中的选定单词CE .
第四 : DeleteOkIssueCriteria() 用于删除列中的选定单词CP .

Sub ReplaceVlookupValues()
'Copy A Range of Data
Worksheets("WC").Range("A3:CP35000").Copy

'PasteSpecial Values Only
Worksheets("WC").Range("A3").PasteSpecial Paste:=xlPasteValues

'Clear Clipboard (removes "marching ants" around the original data set)
Application.CutCopyMode = False

End Sub


Sub DeleteStatus()
Application.ScreenUpdating = False
Dim toDelete As Variant

' set the words to delete
toDelete = Array("Closed", "Resigned", "TBC")

Dim colD As Range
Set col = Sheet1.Range("H3:H" & Sheet1.Range("H" & Rows.Count).End(xlUp).Row)

With col
.AutoFilter Field:=1, Criteria1:=toDelete, Operator:=xlFilterValues
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With

Sheet1.AutoFilterMode = False
End Sub


Sub DeleteEmployeeCriteria()
Application.ScreenUpdating = False
Dim toDelete As Variant

' set the words to delete
toDelete = Array("0NotEmployee", "1NotEmployee")

Dim colD As Range
Set col = Sheet1.Range("CE3:CE" & Sheet1.Range("CE" & Rows.Count).End(xlUp).Row)

With col
.AutoFilter Field:=1, Criteria1:=toDelete, Operator:=xlFilterValues
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With

Sheet1.AutoFilterMode = False

End Sub


Sub DeleteOkIssueCriteria()
Application.ScreenUpdating = False
Dim toDelete As Variant

' set the words to delete
toDelete = Array("OK")

Dim colD As Range
Set col = Sheet1.Range("CP3:CP" & Sheet1.Range("CP" & Rows.Count).End(xlUp).Row)

With col
.AutoFilter Field:=1, Criteria1:=toDelete, Operator:=xlFilterValues
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With

Sheet1.AutoFilterMode = False

End Sub

1 Câu trả lời

我的评论示例:

Sub Execute_Routines()
With Application
.EnableEvents = False
.ScreenUpdating = False
.Calculate = xlManual
'---
ReplaceVlookupValues
DeleteEmployeeCriteria
DeleteOkIssueCriteria
'---
.EnableEvents = True
.ScreenUpdating = True
.Calculate = xlAutomatic
End with
End Sub
如果您在单个模块中,则上述方法有效。如果您在其他模块中工作,您将需要引用,并且可能需要实际使用 Call .

关于excel - 如何将所有这些代码放在一起以作为一个模块运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72048113/

27 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com