如何根据excel VBA中的行和列ID查找单元格值 [英] How to find cell value based on row and Column ID in excel VBA
本文介绍了如何根据excel VBA中的行和列ID查找单元格值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要VBA子查找基于行和列ID的单元格值。
在下面的例子中,我需要选择East和RT3相交的值为80。
Need a VBA Sub to find a cell value based on Row and Column ID. In the example below I need to select the value where East and RT3 intersect which is 80.
A B C D E
1 null RT1 RT2 RT3 RT4
2 North 31 40 78 11
3 South 32 41 79 12
4 East 33 42 80 13
5 West 34 43 81 14
推荐答案
使用类似于未测试的 :
Function getcell(ct as string, rt as string) as range
With activecell
R = .columns("A").find(rt).row
C = .rows("1").find(ct).Column
'The below will escape the function if none where found
If r = nothing or c = nothing then exit function
Set getcell = .cells(r, c)
End with
End function
这篇关于如何根据excel VBA中的行和列ID查找单元格值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文