LearnMeExcel
Well-known Member
- Joined
- Aug 11, 2009
- Messages
- 746
- Office Version
- 365
- 2021
- Platform
- Windows
HI
i am trying to learn VBA
and i try this code
with this data
Excel 2007
i know we can do it by Formula
but
what is the wronge with my code
i am trying to learn VBA
and i try this code
Code:
Sub IndexwithMatch()
Dim LR As Integer
LR = Range("a" & Rows.Count).End(xlUp).Row
WorksheetFunction.Index(range("a4:a" & LR),WorksheetFunction.Match(Range("a1"),range("b4:b" & LR),false))
End Sub
Excel Workbook | ||||
---|---|---|---|---|
A | B | |||
1 | Local | |||
2 | ||||
3 | Names | |||
4 | Name1 | not | ||
5 | Name2 | Yet | ||
6 | Name3 | Do | ||
7 | Name4 | Local | ||
8 | Name5 | ok | ||
Sheet1 |
i know we can do it by Formula
Code:
=INDEX(A4:A8,MATCH(A1,B4:B8,0))
what is the wronge with my code