Excel的行的提取?谁告诉我
答案:2 悬赏:0 手机版
解决时间 2021-02-19 21:06
- 提问者网友:听门外雪花风
- 2021-02-19 16:47
现在我有很多的EXCEL的文件,每个文件中的A中 在不同的行里有相同的012304,我想把这些所有带有012304的行都提取到一个新的EXCEL表中要怎么办??
最佳答案
- 五星知识达人网友:白昼之月
- 2021-02-19 17:36
是不是每个文件的第一个sheet的A列,用vba,代码如下:
Sub aa()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim myDialog As FileDialog, oFile As Object, strName As String, n As Integer
Dim FSO As Object, myFolder As Object, myFiles As Object
n = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set myFolder = FSO.GetFolder(ThisWorkbook.Path)
Set myFiles = myFolder.Files
For Each oFile In myFiles
strName = UCase(oFile.Name)
strName = VBA.Right(strName, 3)
If strName = "XLS" And oFile.Name <> ThisWorkbook.Name Then
Cells(n, 1) = oFile.Name
fn = ThisWorkbook.Path & "\" & Cells(n, 1)
Workbooks.Open Filename:=fn
Workbooks(oFile.Name).Activate
With Sheets(1)
m = 1
For n = 1 To .Range("a1").CurrentRegion.Row
If .Range("a" & n) = "012304" Then
Rows(n).Copy
ThisWorkbook.Activate
Rows(m).Select
ActiveSheet.Paste
m = m + 1
End If
Workbooks(oFile.Name).Close SaveChanges:=False
Exit For
Next n
End With
n = n + 1
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
把以上代码放在宏里面,并将文件保存在其它excel文件同一个文件夹里,运行宏aa即可。
Sub aa()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim myDialog As FileDialog, oFile As Object, strName As String, n As Integer
Dim FSO As Object, myFolder As Object, myFiles As Object
n = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
Set myFolder = FSO.GetFolder(ThisWorkbook.Path)
Set myFiles = myFolder.Files
For Each oFile In myFiles
strName = UCase(oFile.Name)
strName = VBA.Right(strName, 3)
If strName = "XLS" And oFile.Name <> ThisWorkbook.Name Then
Cells(n, 1) = oFile.Name
fn = ThisWorkbook.Path & "\" & Cells(n, 1)
Workbooks.Open Filename:=fn
Workbooks(oFile.Name).Activate
With Sheets(1)
m = 1
For n = 1 To .Range("a1").CurrentRegion.Row
If .Range("a" & n) = "012304" Then
Rows(n).Copy
ThisWorkbook.Activate
Rows(m).Select
ActiveSheet.Paste
m = m + 1
End If
Workbooks(oFile.Name).Close SaveChanges:=False
Exit For
Next n
End With
n = n + 1
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
把以上代码放在宏里面,并将文件保存在其它excel文件同一个文件夹里,运行宏aa即可。
全部回答
- 1楼网友:不甚了了
- 2021-02-19 17:58
两种办法可以将cad图形导入excel。
1、复制,粘贴。首先点击工具栏上的复制按钮,再选中需要导入的图形,后打开excel文件,粘贴后调整图片大小即可。如下图:
2、cad虚拟打印,将cad输出为图片格式,jpg,png均可,生成的图片插入excel中。具体操作方法为,文件—打印,在打印机名称中选择“publishtoweb jpg.pc3”,在图纸尺寸中选择好像素。点击打印会生成一个jpg文件。然后以图片的形式插入excel中。
如下图:
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯