- 帖子
- 561
- 主題
- 160
- 精華
- 0
- 積分
- 725
- 點名
- 0
- 作業系統
- WINDOWS
- 軟體版本
- xp
- 閱讀權限
- 50
- 性別
- 男
- 來自
- 桃園
- 註冊時間
- 2014-9-10
- 最後登錄
- 2024-8-7
  
|
2#
發表於 2017-11-30 16:52
| 只看該作者
如下試試
工作表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) |
|