麝香的养殖:关于表格更新出问题

来源:百度文库 编辑:九乡新闻网 时间:2024/05/05 15:01:50
Private Sub CommandButton2_Click()

Range("A8:n4500").Clear

lbx = Sheet20.ComboBox1.ListIndex
Select Case lbx
Case 0

k3dshijihao = "http://www.17500.cn/getData/3d.TXT"

d3s = "WData3D_All"
    Cells(1, 1) = "3D开奖数据"

    Cells(8, 1) = "开奖期号"
    Cells(8, 2) = "开奖日期"
    Cells(8, 3) = "开"
    Cells(8, 4) = "奖"
    Cells(8, 5) = "号"
   
    Cells(8, 6) = "试"
    Cells(8, 7) = "机"
    Cells(8, 8) = "号"
   
    Cells(8, 9) = "机"
    Cells(8, 10) = "球"
   
    Cells(8, 11) = "投注总额"
    Cells(8, 12) = "直选注数"
    Cells(8, 13) = "其他数据"
   
   
    cz = k3dshijihao: czmc = d3s


     With ActiveSheet.QueryTables.Add(Connection:= _
         "TEXT;" & cz, Destination:=Range("A9"))
        .Name = czmc
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = xlWindows
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = True
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = True
        
        .TextFileParseType = xlFixedWidth
        .TextFileFixedColumnWidths = Array(7, 11, 2, 2, 2, 2, 2, 2, 2, 2, 9, 6)
  
        .Refresh BackgroundQuery:=False
    End With
Range("A" & (Application.Count(Range("a1:a5500")))).Select
'========自动添加下一期数据
s = [a65536].End(xlUp).Row
Cells(s + 1, 1) = Cells(s, 1) + 1 '自动添加下一期期号
Cells(s + 1, 2) = Cells(s, 2) + 1 '自动添加下一期日期

'以上为另外方法
'Dim i As Integer
'i = ActiveSheet.[a65536].End(xlUp).Row + 1
'Cells(i, 1).Value = Cells(i - 1, 1).Value + 1
'以上为另外方法
'========自动添加下一期数据
End



End Select

Select Case lbx
Case 1
k3dshijihao = "http://www.17500.cn/getData/p5.TXT"

d3s = "WData3D_All"
    Cells(1, 1) = "P3/P5开奖数据"

    Cells(8, 1) = "开奖期号"
    Cells(8, 2) = "开奖日期"
    Cells(8, 3) = "开"
    Cells(8, 4) = "奖"
    Cells(8, 5) = "号"
   
    Cells(8, 6) = "P4"
    Cells(8, 7) = "P5"
   
    Cells(8, 8) = " "
   
    Cells(8, 9) = " "
    Cells(8, 10) = " "
   
    Cells(8, 11) = "投注总额"
    Cells(8, 12) = "直选注数"
    Cells(8, 13) = "其他数据"
   
   
    cz = k3dshijihao: czmc = d3s


     With ActiveSheet.QueryTables.Add(Connection:= _
         "TEXT;" & cz, Destination:=Range("A9"))
        .Name = czmc
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = xlWindows
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = True
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = True
        
        .TextFileParseType = xlFixedWidth
        .TextFileFixedColumnWidths = Array(7, 11, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0)
  
        .Refresh BackgroundQuery:=False
    End With
Range("A" & (Application.Count(Range("a1:a5500")))).Select
'========自动添加下一期数据
s = [a65536].End(xlUp).Row
Cells(s + 1, 1) = Cells(s, 1) + 1 '自动添加下一期期号
Cells(s + 1, 2) = Cells(s, 2) + 1 '自动添加下一期日期

'以上为另外方法
'Dim i As Integer
'i = ActiveSheet.[a65536].End(xlUp).Row + 1
'Cells(i, 1).Value = Cells(i - 1, 1).Value + 1
'以上为另外方法
'========自动添加下一期数据



End Select



End Sub