从一系列excel文件中选择数据并将其写入一个Excel工作表 [英] select data from a series of excel files and write them in one excel sheet

查看:88
本文介绍了从一系列excel文件中选择数据并将其写入一个Excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,那里,

一般来说,我在一个文件夹中有很多.xls文件。 从每个文件夹,我需要选择部分数据。他们有不同的范围。 我需要先查找一个单词,然后从单词下面的行中选择数据,然后选择一行空行
行。 这些数字分为两列。 选择数字后,我需要将它们放在另一张excel表中。例如,我有三个.xls文件,我必须安排选择的数据 在新的Excel工作表的A-F列中。 这个新的excel
表实际上是在现有的.xls中。  

Generally, I have many .xls files in one folder.  From each folder , I need to select part of the data. They have different range.  I need to look up a word first, and select the data from the row below the word to a row after which is a blank row.  The numbers are in two columns.  After i select the numbers, i need to put them in another excel sheet. for example i have three .xls files, i have to arrange the data selected  in A-F columns in the new excel sheet.  This new excel sheet is actually in an existing .xls.  

现在,我只知道如何打开文件(从这个网站搜索并找到如下代码),但不知道如何查找工作,选择数据并写入新的Excel工作表。  

Right now, I only know how to open the files ( search from this website and find the code as below) , but do not know how to look up the work, select the data and write in the new excel sheet.  

Dim strFilename As String

    Dim strPath As String

    Dim wbkTemp As Workbook

    

    strPath =" xxxxxxxx"

    strFilename = Dir(strPath&" * .xls")

   做Len(strFilename)> 0

       设置wbkTemp = Workbooks.Open(strPath& strFilename)

        

        '
$
        '使用工作簿执行代码

        '
$
        '保存并关闭它
        wbkTemp.Close True

                

        strFilename = Dir

   循环

Dim strFilename As String
    Dim strPath As String
    Dim wbkTemp As Workbook
    
    strPath = "xxxxxxxx"
    strFilename = Dir(strPath & "*.xls")
    Do While Len(strFilename) > 0
        Set wbkTemp = Workbooks.Open(strPath & strFilename)
        
        '
        ' do your code with the workbook
        '
        ' save and close it
        wbkTemp.Close True
                
        strFilename = Dir
    Loop

你能帮我解决这个问题吗?

Could you please help me with this?

对于VBA初学者,尤其是excel应用程序,你有推荐的书籍或推荐吗? 

And for a VBA beginner especially for excel applications, do you have any book or reference recommended? 

非常感谢。

 

推荐答案

你能否在SkyDrive / Sendspace上传2/3样本。这对编程很有帮助。
Could you upload 2/3 sample in SkyDrive/Sendspace.It will be helpful to program.


这篇关于从一系列excel文件中选择数据并将其写入一个Excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆