急性胃炎相关

首页 » 常识 » 预防 » 李津大局观VBA编程用excel自动化读
TUhjnbcbe - 2025/3/7 18:24:00
北京治疗白癜风医院哪个好 http://bdfyy999.com/

众所周知,上班是不能炒股的,也不能玩手机,那么如何看行情呢。很简单,用VBA写个宏在excel表格里面自动读取数据就好

有了这个东西,excel表格中分析概率计算各种指标,那不是信手拈来。Excel的数据分析功能非常强大,你可以利用它进行概率分析、风险评估等。例如,通过蒙特卡洛模拟,可以预测股票价格的波动范围,从而制定相应的投资策略。

图例:按照这样复制粘贴到VBA宏

excel自动化vba读取通达信源代码

PublicConst通达信目录="D:\tdx\"

PublicConst期货日线目录=通达信目录"vipdoc\ds\lday\"

PublicConst期货5分钟目录=通达信目录"vipdoc\ds\fzline\"

PublicConst通达信期货分类文件=通达信目录"T\hq_cache\code2name.ini"

PublicConst上海股票日线目录=通达信目录"vipdoc\sh\lday\"

PublicConst上海股票5分钟目录=通达信目录"vipdoc\sh\fzline\"

PublicConst深圳股票日线目录=通达信目录"vipdoc\sz\lday\"

PublicConst深圳股票5分钟目录=通达信目录"vipdoc\sz\fzline\"

TypeMyType

a1AsLong日期

a2AsLong开盘价

a3AsLong最高价

a4AsLong最低价

a5AsLong收盘价

a6AsSingle成交金额

a7AsLong成交量

a8AsLong李津

EndType

SubUpdate()

DimtempAsMyType,Irow,File1%,hy$,tAsSingle,Rarr(),Karr(),kcount%,i%,x%

t=Timer

hy=上海股票日线目录"sh.Day"

File1=FreeFile

OpenhyForBinaryAccessReadAs#File1

Irow=1

DoWhileNotEOF(File1)

ReDimPreserveRarr(1To13,1ToIrow)

Get#File1,,temp

Rarr(1,Irow)=Format(temp.a1,"-00-00")

Rarr(2,Irow)=temp.a2/

Rarr(3,Irow)=temp.a3/

Rarr(4,Irow)=temp.a4/

Rarr(5,Irow)=temp.a5/

Rarr(6,Irow)=temp.a6

Rarr(7,Irow)=temp.a7

Irow=Irow+1

Loop

Close#File1

Karr=Application.Transpose(Rarr)

WithSheet2

.Range("A2:G"Cells(Rows.Count,1).End(xlUp).Row).ClearContents

.Cells(2,1).Resize(Irow-2,13)=Karr

EndWith

EndSub

excel自动化成品效果:

1
查看完整版本: 李津大局观VBA编程用excel自动化读