Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 3932|回复: 3

[已解决]求助 :如何用VBA导入外管局网站某一天的汇率

[复制链接]
发表于 2010-5-6 10:41 | 显示全部楼层 |阅读模式

求助 :

如何用VBA导入外管局网站 :http://www.safe.gov.cn/model_safe/index.html  某一天的汇率

最佳答案
2010-5-6 11:00
Sub 查询()
    Dim sDate As Date
    sDate = Application.InputBox("请输入日期", "输入", Date)
    Cells.Clear
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.safe.gov.cn/model_safe/search/rmb.jsp?sdate=" & sDate, _
        Destination:=Range("A1"))
        .Name = "我的查询"
        .PreserveFormatting = True
        .WebTables = "2"
        .Refresh
    End With
End Sub
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2010-5-6 10:47 | 显示全部楼层

录个宏呗!:

Sub aa()
With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.safe.gov.cn/model_safe/index.html", Destination:=Range("A1"))
        .Name = "index"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "21"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
End Sub

回复

使用道具 举报

发表于 2010-5-6 11:00 | 显示全部楼层    本楼为最佳答案   

Sub 查询()
    Dim sDate As Date
    sDate = Application.InputBox("请输入日期", "输入", Date)
    Cells.Clear
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.safe.gov.cn/model_safe/search/rmb.jsp?sdate=" & sDate, _
        Destination:=Range("A1"))
        .Name = "我的查询"
        .PreserveFormatting = True
        .WebTables = "2"
        .Refresh
    End With
End Sub
回复

使用道具 举报

发表于 2010-5-6 12:49 | 显示全部楼层

[em05][em05][em05][em05]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-17 06:31 , Processed in 0.266698 second(s), 9 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表