由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Quant版 - VBA code sos
相关主题
a simple vba programming question[Charlotte NC]3 desk quant/financial engineer openings
EXCEL VBA in real world[CT]Quant Developer
请教VBA(macro 跟 user defined function)[合集] Monte Carlo 如何把Matlab的控制结构转换成Excel程序?
How to define the correlation of two variable X and Y defined in different domain?[合集] Implied Volatility计算的麻烦
Hedge Fund Software Programmer and/or Network Administrator[合集] 问个Excel+VBA的问题
[合集] 如果只是programmer也是经常加班的吗Where to learn VBA
[合集] 烂校物理PhD也想来尝尝这quant的天鹅肉If I am only familiar with matlab and VBA,
[NYC]Quantitative Strategistcourses related to energy quant
相关话题的讨论汇总
话题: namefile1话题: vba话题: mycount话题: bb话题: defined
进入Quant版参与讨论
1 (共1页)
i**M
发帖数: 108
1
ThisWorkbook.Activate
Sheets("aa").Activate
mycount = Application.CountA(Range("A5:A100"))

For i = 2 To mycount

transdate = Cells(i, 1).Text
NameFile1 = "C:\Documents and Settings\Desktop" & bb& ".xlsx"
Set wb =Workbooks.Open(Filename:=NameFile1)
Next i
I want to read files' name from a spreadsheet and open those files. The
above is the vba code I wrote, but i got "application defined or object
defined error". I am a beginner of vba, anyone please help me. Thanks a
bunch!
S*********g
发帖数: 5298
2
what is bb?

【在 i**M 的大作中提到】
: ThisWorkbook.Activate
: Sheets("aa").Activate
: mycount = Application.CountA(Range("A5:A100"))
:
: For i = 2 To mycount
:
: transdate = Cells(i, 1).Text
: NameFile1 = "C:\Documents and Settings\Desktop" & bb& ".xlsx"
: Set wb =Workbooks.Open(Filename:=NameFile1)
: Next i

i**M
发帖数: 108
3

bb is a string variable defined already

【在 S*********g 的大作中提到】
: what is bb?
S*********g
发帖数: 5298
4
你用F8一行一行的运行,看看是在那一行出的错

【在 i**M 的大作中提到】
:
: bb is a string variable defined already

i**M
发帖数: 108
5

Workbooks.Open Filename:=NameFile1
is wrong, but have no idea how to fix it

【在 S*********g 的大作中提到】
: 你用F8一行一行的运行,看看是在那一行出的错
S*********g
发帖数: 5298
6
你的问题不在这一行。
bb&应该是bb &,否则应该编译不通过
另外你这个bb在这段code里没有定义,bb和你的循环变量没有关系
我估计你的问题是在bb这个变量

【在 i**M 的大作中提到】
:
: Workbooks.Open Filename:=NameFile1
: is wrong, but have no idea how to fix it

i**M
发帖数: 108
7
Thanks for reply. I just replaced my variable by bb and i wrote & bb & in my
code. when I delete that open file code, it comliles alright.

【在 S*********g 的大作中提到】
: 你的问题不在这一行。
: bb&应该是bb &,否则应该编译不通过
: 另外你这个bb在这段code里没有定义,bb和你的循环变量没有关系
: 我估计你的问题是在bb这个变量

b***a
发帖数: 11
8
"C:\Documents and Settings\Desktop"
后面要加"\"

【在 i**M 的大作中提到】
: Thanks for reply. I just replaced my variable by bb and i wrote & bb & in my
: code. when I delete that open file code, it comliles alright.

S*******r
发帖数: 11017
9
bingo

【在 b***a 的大作中提到】
: "C:\Documents and Settings\Desktop"
: 后面要加"\"

1 (共1页)
进入Quant版参与讨论
相关主题
courses related to energy quantHedge Fund Software Programmer and/or Network Administrator
VBA help wanted[合集] 如果只是programmer也是经常加班的吗
[London]Jr FX Option Quant[合集] 烂校物理PhD也想来尝尝这quant的天鹅肉
Lehman Asia looking for Research Analysts in Hong Kong[NYC]Quantitative Strategist
a simple vba programming question[Charlotte NC]3 desk quant/financial engineer openings
EXCEL VBA in real world[CT]Quant Developer
请教VBA(macro 跟 user defined function)[合集] Monte Carlo 如何把Matlab的控制结构转换成Excel程序?
How to define the correlation of two variable X and Y defined in different domain?[合集] Implied Volatility计算的麻烦
相关话题的讨论汇总
话题: namefile1话题: vba话题: mycount话题: bb话题: defined