在VBA中使用记录集excel [英] Using recordset in VBA excel

查看:137
本文介绍了在VBA中使用记录集excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Excel中有大量数据(16个文件,其中300,000行,每列65列)。我试图通过vba分析数据(对于记录集根据标准获取数据的每个文件)。对于12个文件它可以工作,但是当我增加涉及vba刚刚死亡的文件时,
打开并从第12个文件中获取信息。

解决方案

您好,


您收到任何错误吗?你是什​​么意思VBA死了? Excel会崩溃吗?


根据您的描述,我建议您专门连接这些文件以确认连接是否适用于每个文件,然后将它们合并到一个循环中。 


从您的连接字符串,您是否连接到.xlsb文件?


对于不同的文件扩展名,连接字符串中的extendeed属性会有所不同。


xlsx文件:


提供商 = Microsoft.ACE.OLEDB.12.0; 数据源 = c:\ myFolder \ myExcelfile.xlsx;

扩展属性
= " Excel 12.0 Xml; HDR = YES";


将数据作为文本处理


提供商 = Microsoft.ACE.OLEDB.12.0; 数据源 = c:\ myFolder \\ \\ myExcelfile.xlsx;

扩展属性
= " Excel 12.0 Xml; HDR = YES; IMEX = 1";


Xlsb文件:


提供商 = Microsoft.ACE.OLEDB.12.0;

数据源
= c:\\ \\ myFolder \ myBinaryExcelfile.xlsb;

扩展属性
= " Excel 12.0; HDR = 是" ;;


Xlsm文件:


提供商 = Microsoft.ACE.OLEDB.12.0; 数据源 = c:\ myFolder \ myExcelfile.xlsm;

扩展属性
= " Excel 12.0宏; HDR = 是" ;;


问候,


Celeste


I have a huge data (16 files with 300,000 rows and 65 columns in each) in excel. I am trying to analyse the data via vba (For each file the recordset takes the data based on criteria). For 12 files it works, however when I increase the files involved the vba just dies, after opening and taking the information from 12th file.

解决方案

Hello,

Do you get any error? What do you mean VBA dies? Does Excel crash ?

According to your description, i would suggest you connect to these file sperately to confirm the connection works for every file, then combine them in a loop. 

From your connection string, do you connected to .xlsb files?

For different file extension, the extendeed properties would be different in the connection string.

xlsx file:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcelfile.xlsx;
Extended Properties
="Excel 12.0 Xml;HDR=YES";

Treating data as text

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcelfile.xlsx;
Extended Properties
="Excel 12.0 Xml;HDR=YES;IMEX=1";

Xlsb files:

Provider=Microsoft.ACE.OLEDB.12.0;
Data Source
=c:\myFolder\myBinaryExcelfile.xlsb;
Extended Properties
="Excel 12.0;HDR=YES";

Xlsm file:

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcelfile.xlsm;
Extended Properties
="Excel 12.0 Macro;HDR=YES";

Regards,

Celeste


这篇关于在VBA中使用记录集excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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