Excel精英培训网

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

[已解决]高手,帮我看看这个附档按钮2为什么点击失败,按钮1是OK的。谢谢

[复制链接]
发表于 2015-9-24 16:29 | 显示全部楼层 |阅读模式
高手,帮我看看这个附档按钮2为什么点击失败,按钮1是OK的。谢谢
最佳答案
2015-9-25 08:56
Public Sub CommandButton1_Click()
    With Me
        .Columns("A:P").ClearContents
        With .QueryTables.Add(Connection:="URL;http://taobao.cjcp.com.cn/cjwssc ... gxissc-0-3-840.html", _
                              Destination:=.Range("A1"))
'            .Name = "29_4"
'            .FieldNames = True
'            .RowNumbers = False
'            .FillAdjacentFormulas = False
'            .PreserveFormatting = True
'            .RefreshOnFileOpen = False
'            .BackgroundQuery = True
'            .RefreshStyle = xlInsertDeleteCells
'            .SavePassword = False
'            .SaveData = True
'            .AdjustColumnWidth = True
'            .RefreshPeriod = 0
'            .WebSelectionType = xlAllTables
'            .WebFormatting = xlWebFormattingNone
'            .WebPreFormattedTextToColumns = True
'            .WebConsecutiveDelimitersAsOne = True
'            .WebSingleBlockTextImport = False
'            .WebDisableDateRecognition = False
'            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
    End With
End Sub
123c.rar (57.4 KB, 下载次数: 2)

123.rar

21.16 KB, 下载次数: 9

发表于 2015-9-24 20:01 | 显示全部楼层
Public Sub CommandButton1_Click()
    Me.Select
    Columns("A:P").Select
    Selection.ClearContents
    Range("A1").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://taobao.cjcp.com.cn/cjwssc ... gxissc-0-3-840.html", Destination _
        :=Range("A1"))
        .Name = "29_4"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlAllTables
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
End Sub
123b.rar (55.22 KB, 下载次数: 8)
回复

使用道具 举报

 楼主| 发表于 2015-9-25 08:24 | 显示全部楼层
爱疯 发表于 2015-9-24 20:01
Public Sub CommandButton1_Click()
    Me.Select
    Columns("A:P").Select

谢谢老大,但是还有一个问题是,点击按钮2后不需要跳到按钮1表格中,让它默默的运行就行了,因为我的按钮1表格可能是要隐藏起来的
回复

使用道具 举报

发表于 2015-9-25 08:56 | 显示全部楼层    本楼为最佳答案   
Public Sub CommandButton1_Click()
    With Me
        .Columns("A:P").ClearContents
        With .QueryTables.Add(Connection:="URL;http://taobao.cjcp.com.cn/cjwssc ... gxissc-0-3-840.html", _
                              Destination:=.Range("A1"))
'            .Name = "29_4"
'            .FieldNames = True
'            .RowNumbers = False
'            .FillAdjacentFormulas = False
'            .PreserveFormatting = True
'            .RefreshOnFileOpen = False
'            .BackgroundQuery = True
'            .RefreshStyle = xlInsertDeleteCells
'            .SavePassword = False
'            .SaveData = True
'            .AdjustColumnWidth = True
'            .RefreshPeriod = 0
'            .WebSelectionType = xlAllTables
'            .WebFormatting = xlWebFormattingNone
'            .WebPreFormattedTextToColumns = True
'            .WebConsecutiveDelimitersAsOne = True
'            .WebSingleBlockTextImport = False
'            .WebDisableDateRecognition = False
'            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=False
        End With
    End With
End Sub
123c.rar (57.4 KB, 下载次数: 2)

评分

参与人数 1 +1 收起 理由
hpleo8 + 1 很给力!

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2015-9-25 09:38 | 显示全部楼层
爱疯 发表于 2015-9-25 08:56
Public Sub CommandButton1_Click()
    With Me
        .Columns("A:P").ClearContents

谢谢老大,可以了。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-29 05:54 , Processed in 0.425640 second(s), 13 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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