|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
我需要根据当前工作表的件号,查询数据源工作薄"常用件价格表"内的对应这个件号的价格一栏数据,填入当前工作表参考价格一栏当运行的结果总是空的,我看下了下R值始终是空的,直接跳过了,
请老师们指导下,我是刚刚才接触这个的新手,万分感谢
Sub 查常用件价格表()
Dim k As Integer, j As Integer
Dim wb As Workbook, w As Worksheet, r As Worksheet
Set r = ActiveSheet
Application.DisplayAlerts = False
Set wb = Workbooks.Open("G:\VB\常用件价格表.xlsx")
k = 3
Do While r.Cells(k, 2) <> ""
For Each w In wb.Worksheets
j = 2
Do While w.Cells(j, 3) <> ""
If LCase(Trim(w.Cells(j, 4))) = LCase(Trim(r.Cells(k, 3))) Then
r.Cells(k, 13) = w.Cells(j, 7)
End If
j = j + 1
Loop
Next
k = k + 1
Loop
wb.Close
Application.DisplayAlerts = True
End Sub
|
|