1樓:慶年工坊
function myvlookup(val, rg as range, n as integer, f as boolean)
arr = rg
if f then
for i = ubound(arr) to 1 step -1if val >= arr(i, 1) thenmyvlookup = arr(i, n)end function
end if
next
else
for i = 1 to ubound(arr)if val = arr(i, 1) thenmyvlookup = arr(i, n)end function
end if
next
end if
myvlookup = "nothing is find!"
end function
2樓:
sub test()
dim dic as object,mary,mrow as long,
set dic=createobject("scripting.dictionary")
with worksheets("資料")
mrow=.cells(.rows.count,1).end(3).row
mary=.[a2].resize(mrow-1,2)
end with
for i=1 to ubound(mary,1)
dic("" & mary(i,1))=mary(i,2)
next i
with worksheets("求解表")
mrow=.cells(.rows.count,1).end(3).row
mary=.[a2].resize(mrow-1,1)
for i=1 to ubound(mary,1)
if dic.exists("" & mary(i,1)) then
mary(i,1)=dic.exists("" & mary(i,1))
else
mary(i,1)="no find!"
end if
next i
.[b2].resize(ubound(mary,1),1)=mary
end with
end sub
3樓:矮漢恨天高
既然使用了vba就沒必要再使用內建函式,vba可以把vlookup重新定義。
4樓:毋亙
vba不見得比內建函式快哦
5樓:匿名使用者
上傳附件 我看看
留個聯絡唄
如何在啟用excel時自動執行vba的某個巨集
1 首先將excel文件 預設新建副檔名為xlsx 另存為啟用巨集的工作簿,副檔名為xlsm。2 按下組合鍵alt f11快速切換到vba視窗。3 進入vba視窗後的介面,如圖所示。4 雙擊thisworkbook後,會彈出一個 視窗。6 儲存,關閉,重新開啟excel 副檔名為xlsm 文件,效果...
在Excel中用vba程式設計達到預期效果,滿意後追加獎賞
不是所有問題都用vba就好,你這個問題根本不用vba,用公式判斷如果產品名稱相同,就用前列 減後列 否則就返回空,用vba反而把簡單問題複雜化了。例如公式 if a1 c1,b1 d1,q15963970 乾咳要用vba用公式就可以啊 看看是不是你想要的 sub test rowmax sheets...
excel中用VBA提出一列資料中含有0369數字的單元格
sub aa dim m 記錄相同數 dim ro as integer 記錄符合結果數字所在行k activesheet.range c1 c65536 end xldown row ro k for i k to 1 step 1m 0 for j 1 to len cells i,3 a mi...