- 帖子
- 552
- 主題
- 3
- 精華
- 0
- 積分
- 578
- 點名
- 0
- 作業系統
- win7
- 軟體版本
- office 2010
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2015-2-8
- 最後登錄
- 2024-7-9
  
|
2#
發表於 2016-8-15 17:36
| 只看該作者
本帖最後由 lpk187 於 2016-8-15 17:46 編輯
回復 1# VBALearner
程式有誤已幫你修正,日期必須宣告為Date ,Find才會找到
應該要養成宣告變數的習慣!- Sub test()
- Dim rng1 As Range, rng2 As Range
- Dim 日期 As Date
- With Sheets(1)
- 號碼 = .Cells(3, 18)
- 日期 = .Cells(2, 19)
- '.Activate'這行可以不用
- Set rng1 = .Columns(1).Find(號碼)
- Set rng2 = .Rows(1).Find(日期, LookIn:=xlValues)
- .Cells(3, 19) = .Cells(rng1.Row, rng2.Column).Value
- End With
-
- End Sub
複製代碼 |
|