gpt4 book ai didi

vba - 删除 Material 明细表中的行

转载 作者:行者123 更新时间:2023-12-05 00:18:47 25 4
gpt4 key购买 nike

我目前正在尝试制作可以过滤我的 BOM( Material list )表的宏,但它不断收到错误消息。

目标是删除第 9 列中包含文本“No”的所有行,有人可以帮我解决这个问题吗?

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc

Dim swSelMgr As SldWorks.SelectionMgr

Dim swView As SldWorks.View

Dim swBomTable As SldWorks.BomTableAnnotation

Dim i As Integer

Dim swTableAnn As SldWorks.TableAnnotation

Dim nNumRow As Variant

Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swSelMgr = swModel.SelectionManager

Set swBomTable = swSelMgr.GetSelectedObject5(1)

Set swTableAnn = swBomTable



For i = swTableAnn.RowCount - 1 To 0 Step -1

nNumRow = swBomTable.GetIdForRowNumber(i)


If nNumRow(i, 9) = "No" Then

swBomTable.Deleterow (nNumRow), True

End If

Next i

End Sub

最佳答案

注意这会删除所有“否”行.. 就像 Nothing nowhere No NO no 如果您想寻找独立的 no 则在“no”每一侧的代码中添加空格 -> “no”

Option Compare Text
Sub deleter()
Dim xrow As Long
Dim lastrow As Long

lastrow = Cells(65000, 9).End(xlUp).Row + 1
xrow = 1

Do
If Not InStr(1, Cells(xrow, 9).Value, "No") = 0 Then
Cells(xrow, 9).EntireRow.delete
Else
xrow = xrow + 1
End If
Loop Until xrow = lastrow
End Sub

如果您需要仅使用大写字母查找“否”,请随意删除选项“比较文本”希望我能帮上忙

关于vba - 删除 Material 明细表中的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34087325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com