|
从一个大表里筛选部分信息 复制到新的表格里 执行程序没反应
Private Sub CommandButton1_Click()
'iFileName = Application.GetOpenFilename
'读取材料价格清单文件
With Application.FileDialog(msoFileDialogFilePicker)
.InitialFileName = ThisWorkbook.Path '设置默认文件路径
.AllowMultiSelect = False
'单选择
.Filters.Clear
'清除文件过滤器
.Filters.Add "Excel Files", "*.xls;*.xlw;*.xlsx;*.xlsm"
'.Filters.Add "All Files", "*.*" 设置第二个文件过滤器
If .Show = -1 Then
'FileDialog 对象的 Show 方法显示对话框,并且返回 -1(如果您按 OK)和 0(如果您按 Cancel)。
'MsgBox "您选择的文件是:" & .SelectedItems(1), vbOKOnly + vbInformation, "智能Excel"
eText1.Text = .SelectedItems(1)
End If
End With
End Sub
Sub 家装库()
Dim Mywb As Workbook, Myws As Worksheet
Dim rng As Range, rngA As Range
For Each Mywb In Workbooks
With Mywb
For Each Myws In .Worksheets
On Error Resume Next
Set rngA = Myws.UsedRange.SpecialCells(xlCellTypeFormulas)
'获取公式单元格区域引用
For Each rng In rngA
rng.Value = rng.Value '将公式转换成数值
Next
Next
End With
Next
Columns("X:AJ").Delete
Columns("Y:BJ").Delete
If Len(eText1) <> 0 Then ' And Len(eText2) <> 0
sPath = ThisWorkbook.Path & "\生成产品库"
End If
Dim k As Long, Arr
Arr = [a1].CurrentRegion
For k = UBound(Arr) To 1 Step -1
If InStr(Arr(k, 3), "在售") + _
InStr(Arr(k, 6), "√") Then
Workbooks.Add
[a1].CurrentRegion.SpecialCells(xlCellTypeVisible).Copy nembk.Sheet(1).[a1]
ActiveSheet.SaveAs ThisWorkbook.Path & "\生成产品库\" & 家装产品库
If InStr(Arr(k, 3), "在售") + _
InStr(Arr(k, 7), "√") Then
Workbooks.Add
[a1].CurrentRegion.SpecialCells(xlCellTypeVisible).Copy nembk.Sheet(1).[a1]
ActiveSheet.SaveAs ThisWorkbook.Path & "\生成产品库\" & 工装产品库
Next
End If
End If
Application.ScreenUpdating = True
End Sub
|
|