Forum Discussion
how do we fill in school.xlsx file age column from age.xlsx file by using name column with visual b
how do we fill in school.xlsx file age column from age.xlsx file by using name column with visual basic excel? Tables have variable length and have more than 10000 rows.
school.xlsx
|A | B | C|
|:---- |:------:| -----:|
|name | code | age|
|peter1 | 254 |
|jane2 |153 |
|ted | 323 |
|peter3 |323 |
age.xlsx
|A |B|
|:---- |:------:|
|name |age|
|mark3| 1,2|
|peter1 | 5 |
|jane2 | 1,5|
'''
Sub Insertdata()
Dim iAge As Integer
Set src=Workbooks.Open("age.xlsx", True, True)
iAge = src.Worksheets("Sheet1").Range("B2").Value
Worksheets("Sheet1").Range("C2").Value = iAge
End Sub
'''
Now the program returns value 1 in field C2 in age.xlsx file.
How do we remake the program to insert age data in right row in shcool.xlsx?
18 Replies
- Riny_van_EekelenPlatinum Contributor
sergey989 Why VBA? A simple VLOOKUP or INDEX/MATCH (or XLOOKUP if your Excel version supports it) can do this.
- sergey989Brass Contributorcan you show me example?
but we have variable length column- Riny_van_EekelenPlatinum Contributor
sergey989 See attached example. I chose to put the data in structured tables. All three lookup methods are in the table at the top under age1, age2 and age3.
See if you can get it to work on your side.