我希望當查詢週次尚未輸入時,能夠在查詢的時候會出現"無此週次",並離開此程序
如果要查詢的週次存在,則繼續程序
不知哪錯了,就是有問題
Private Sub CommandButton1_Click() '查詢
Dim a As Integer
Dim b As Range
Dim t As Range
Dim r As Range
With Sheets("初看未購原因")
Set r = .Range("A4:A" & .Range("A65536").End(xlUp).Row)
On Error Resume Next
d = .Cells(.Range("A4:A").Find(czxm).Row, 1)
If d = czxm Then
MsgBox "無此週次", 0
Exit Sub
End If
End With
With Sheets(5)
Set c = Sheets(2).Range("A:A").Find(czxm, lookat:=xlWhole)
If Not c Is Nothing And czxm > "1" Then
Sheets(5).Range("a5").Value = czxm
Sheets(5).Range("a29").Value = Sheets(2).Cells(c.Row, 2).Value '日期
.Range("a35").Value = .Range("a29").Value + 6 '日期
Arr = Sheets(2).[a4].Resize(c.Row - 4, 36) '增加
Arr1 = Sheets(3).[a4].Resize(c.Row - 4, 36) '增加
Arr2 = Sheets(4).[a4].Resize(c.Row - 4, 36) '增加作者: luhpro 時間: 2010-8-10 00:52
With Sheets("初看未購原因") 紅字的語法錯誤
Set r = .Range("A4:A" .Range("A65536").End(xlUp).Row)
On Error Resume Next
d = .Cells(.Range("A4:A").Find(czxm).Row, 1) =>應簡化為 d =r.Find(czxm)
這是你要的嗎?
With Sheets("初看未購原因")
Set r = .Range("A4:A" & .Range("A65536").End(xlUp).Row) ->修正後
On Error Resume Next
d =r.Find(czxm)作者: olisun 時間: 2010-8-10 10:53
回復 9#olisun
With Sheets("初看未購原因")
Set r = .Range("A4:A" & .Range("A65536").End(xlUp).Row) '
'不要用它On Error Resume Next
If r.Find(czxm) Is Nothing Then
MsgBox "無此週次"
Exit Sub
End If
End With作者: olisun 時間: 2010-8-10 11:30