返回列表 上一主題 發帖

請教vba表單查詢問題

如下試試
    工作表2.[A1:G65536].ClearContents
     X = 工作表1.[A65536].End(xlUp).Row
     Y = 工作表2.[A65536].End(xlUp).Row
     For M = 1 To X
     If 工作表1.Cells(M, 1) = TextBox1.Value Then
     工作表2.Cells(Y + 1, 1).Resize(, 7).Value = 工作表1.Cells(M, 1).Resize(, 7).Value
    Y = Y + 1
    End If
    Next




Private Sub CommandButton2_Click()
    Label15.Caption = ""
    Label16.Caption = ""
    Label17.Caption = ""
    Label18.Caption = ""
    Label19.Caption = ""
    Label20.Caption = ""
    Label21.Caption = ""
    Label22.Caption = ""
    Label23.Caption = ""
    Label24.Caption = ""
    Label25.Caption = ""

    qq = 1
    yy = 1
   
     工作表2.[A1:G65536].ClearContents
     X = 工作表1.[A65536].End(xlUp).Row
     Y = 工作表2.[A65536].End(xlUp).Row
     For M = 1 To X
     If 工作表1.Cells(M, 1) = TextBox1.Value Then
     工作表2.Cells(Y + 1, 1).Resize(, 7).Value = 工作表1.Cells(M, 1).Resize(, 7).Value
    Y = Y + 1
    End If
    Next
   
   
    Do '將sheet1查詢到的資料送到sheet2
        If Sheets(1).Cells(qq, 1) = TextBox1.Text Then
            Label15.Caption = Sheets(1).Cells(qq, 2)
            Label16.Caption = Sheets(1).Cells(qq, 3)
            Label17.Caption = Sheets(1).Cells(qq, 5)
            Label18.Caption = Sheets(1).Cells(qq, 4)
            Label19.Caption = Sheets(1).Cells(qq, 6)
            Label20.Caption = Sheets(1).Cells(qq, 7)
羅

TOP

        靜思自在 : 為人處世要小心細心,但不要「小心眼」。
返回列表 上一主題