从Access导出数据到Excel [英] Export data from Access to Excel

查看:82
本文介绍了从Access导出数据到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Excel模板,我有一些公式,我想从Access Query导出到这个excel电子表格中。我在这个论坛中发现了一些代码,我已经修改了这些代码以适应我的电子表格当我运行该过程时,我得到一个下标超出范围错误9

展开 | 选择 | Wrap | 行号

解决方案

我正在研究这个问题并发现有一半的引用是 xlObj 而另一半是 x1Obj 。现在你不必费心指定你看到错误的哪一行。你需要做的事情(迫切地,为了避免浪费你或我们的时间),就是阅读和消化在发布之前发布(VBA或SQL)代码。如果你这样做,我可以保证你将来也不会遇到这个问题。


无论如何我在查看代码时,我决定稍微改写一下就不会受到伤害并且可以说明一种更清晰的方法来解决这个问题(当你尝试编译任何一个版本时,大部分内容都太难以解决了,但至少在这里有一些想法应该有所帮助。):

展开 | 选择 | Wrap | 行号


我以为我提到它发生在填充数据的第一行。部分。另外我喜欢你在数组中做这个的想法,但是在模板中,每组time1,misses1,penalties1等之后都有总列,所以我将尝试使用你的代码并在每一行都打破它。 / blockquote>

我也查看了每个x1Obj,它们都是一样的。 填写数据的第一行看起来不同,但它是一样的,我试图加粗该行,以显示我收到错误的行。我已经使用Array尝试了代码,但仍然得到了下标范围错误。


I have a Excel template that I have some formulas in I want to export from a Access Query into this excel spread sheet. I found some code in this forum that I have modified to fit my spread sheet. When I run the process I get a "Subscript out of range" error 9

Expand|Select|Wrap|Line Numbers

解决方案

I was working on this and noticed that half the references are to xlObj while the other half were to x1Obj. Now you needn''t bother specifying properly which line you saw the error on. What you do need to do though (urgently, to avoid wasting any more of your, or our, time), is to read and digest When Posting (VBA or SQL) Code before posting again. I can guarantee you won''t even have this problem in future if you do that.

While I was looking at the code anyway, I decided a little rewrite wouldn''t hurt and can illustrate a cleaner way to approach this (Much of it is too broken to fix, as you''ll see when you try to compile either version, but at least there are some ideas in here that should help.) :

Expand|Select|Wrap|Line Numbers


I thought I mentioned that it happens on the very first line in the "fill in data" section. Also I like your idea about doing this in a array but in the template there are total columns after each set of time1,misses1,penalties1 etc so I''m going to try using your code and breaking it at each line of times.


I''ve also looked at each of the x1Obj and they are all the same. The first line of the "fill in Data" looks different but it''s the same I tried to bold that line to show which line I received the error on. I''ve tried the code using the Array and still get the subscript out of range error.


这篇关于从Access导出数据到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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