x = Application.Match(ItemNam, Sheet2.[A1:A100], 0)
Debug.Print x
z = z + 1
Loop
End Sub
複製代碼
作者: am0251 時間: 2011-6-23 13:25
謝謝指教~~!!感覺功力提昇了不小!!作者: GBKEE 時間: 2011-6-23 13:42
本帖最後由 GBKEE 於 2011-6-23 13:46 編輯
回復 8#am0251
Sub test()
Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim ItemName As String
z = 2
Do While Range("A" & z).Value <> ""
'ItemNam = Worksheets("Sheets1").Range("A" & z).Value '你的附檔中沒有Sheets1工作表
'x = Evaluate("MATCH(""ItemNam"",Sheet(Sheets2)!A:A,0)") 你的附檔中沒有Sheets2工作表
'x = Application.WorksheetFunction.Match(Worksheets("Sheets1").Range("A" & z).Value, Sheets("Sheets2").Range("A:A")) '如上的錯誤
ItemNam = Worksheets("Sheet1").Range("A" & z).Value
x = Evaluate("MATCH(""" & ItemNam & """,Sheet2!A:A,0)") 'ItemNam是變數要用&來連接
x = Application.WorksheetFunction.Match(Worksheets("Sheet1").Range("A" & z).Value, Sheets("Sheet2").Range("A:A"))
Debug.Print x, y
z = z + 1
Loop
End Sub作者: am0251 時間: 2011-6-23 13:57
剛好有利用到~~感謝oobird
Private Sub CommandButton1_Click()
Dim x As Integer, y As Integer, z As Integer, ItemName As String
z = 6
Do While Range("N" & z).Value <> ""
ItemNam = Sheet3.Range("N" & z).Value
Sheet3.Range("S" & z).Value = Application.VLookup(ItemNam, Sheet4.[A1:B29], 2, 0)
z = z + 1
Loop
End Sub作者: am0251 時間: 2011-6-25 14:32
本帖最後由 am0251 於 2011-6-25 14:39 編輯
不好意思,小的沒看懂....這是我的程序
Private Sub Start_Click()
Dim x As Integer, y As Integer, z As Integer, S1 As Integer, S2 As Integer, myRowCount As Integer