返回列表 上一主題 發帖

欲建立資料篩選系統

初學者給大大一些建議
先從同一工作簿開始練習(雖然只差一個Workbooks.Open而已)

sshot-2.png

以下為查詢部分(初學者寫法僅供參考)
  1.     XD = TextBox1.Text
  2.     Sheets("資料庫").Select
  3.     Set FindCell = Cells.Find(What:=XD, After:=ActiveCell, LookIn:=xlFormulas, _
  4.        LookAt:=1, SearchOrder:=2, SearchDirection:=xlNext, _
  5.        MatchCase:=False, MatchByte:=False, SearchFormat:=True)
  6.         If Not FindCell Is Nothing Then
  7.             xj = Sheets("查詢").[A65536].End(xlUp).Row + 1
  8.             Rows(FindCell.Row).Copy Sheets("查詢").Cells(xj, 1)
  9.         Else
  10.             MsgBox "查無"
  11.         End If
複製代碼

TOP

看錯了...是篩選
  1.     Set WB = Workbooks.Open(ThisWorkbook.Path & "\資料庫.xlsx")
  2.     Set Sht = WB.Worksheets(1)
  3.     With Sht
  4.         .Rows(1).AutoFilter
  5.         .UsedRange.AutoFilter Field:=3, Criteria1:="查詢條件"
  6.         .UsedRange.Copy ThisWorkbook.Worksheets("查詢").Range("A1")
  7.     End With
  8.     WB.Close False
複製代碼

TOP

        靜思自在 : 人要知福、惜福、再造福。
返回列表 上一主題