|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
cjf丶 发表于 2015-4-23 08:27
自己顶一个~!!
无法保存到文件,只有把代码给你,你试一下吧
Sub 按表名在工作薄中取数()
With ActiveWorkbook
Application.ScreenUpdating = False
lj = ActiveWorkbook.Path
dirname = Dir(lj & "\" & "*.dat")
Do While dirname <> ""
Workbooks.Open filename:=lj & "\" & dirname
lh = Range("iv4").End(xlToLeft).Column
For Each sht In .Worksheets
ming = "[" & sht.Name & "]"
lh0 = sht.Range("iv4").End(xlToLeft).Column + 1
For i = 1 To lh
ku = Replace(Cells(1, i), " ", "")
If ming = ku Then Range(Cells(1, i), Cells(65536, i)).Copy sht.Cells(1, lh0): lh0 = lh0 + 1
Next
Next
ActiveWorkbook.Close
dirname = Dir
Loop
For Each sht In .Worksheets
If sht.[a1] = "" Then sht.Columns(1).Delete
Next
End With
Application.ScreenUpdating = True
End Sub
|
|