vlook and match VBA code

rzml

New Member
Joined
Dec 24, 2020
Messages
26
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I am new to VBA and trying to automate finding marks from one sheet to another (sheet using vlookup and match. I used the below VBA code but it's not working.


Public Sub testinputbox()
'id of student that you want to search for his mark (argument 1)
Dim id2sr As Range
'evaluation row to search (argument 2)
Dim qz2sr As Range
'the sheet or table you want to search
Dim data1 As Range
'the quiz row from database
Dim qzrow As Range

Dim mark As Integer
mark = ActiveCell.Value

Set id2sr = Application.InputBox("where is id in question", , , , , , , 8)
Set qz2sr = Application.InputBox("where is evaluation row in question?", , , , , , , 8)
Set data1 = Application.InputBox("where is the database of marks?", , , , , , , 8)
Set qzrow = Application.InputBox("where is evaluation row in data base?", , , , , , , 8)

mark = Application.WorksheetFunction.VLookup(id2sr, data1, Application.WorksheetFunction.Match(qz2sr, qzrow, False), False)



End Sub
1609220419118.png
1609220464459.png




Thanks
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,247
Office Version
  1. 2013
Platform
  1. Windows
You said:
I am new to VBA
But then showed us a lot of code you wrote that does not do what you want.

Would you please just say in words what your wanting to do.
Thanks

And please do not say use Vlookup.
Let me decide how we may want to do it.
 

rzml

New Member
Joined
Dec 24, 2020
Messages
26
Office Version
  1. 2016
Platform
  1. Windows
You said:
I am new to VBA
But then showed us a lot of code you wrote that does not do what you want.

Would you please just say in words what your wanting to do.
Thanks

And please do not say use Vlookup.
Let me decide how we may want to do it.
I am trying to get marks from a database of marks to the other sheet. the code should search for the mark based on the student ID and type of assessment. I use a lot of code, but I have just started learning 2 days ago hence the " I am new ".
 

Watch MrExcel Video

Forum statistics

Threads
1,118,521
Messages
5,572,628
Members
412,475
Latest member
JaredNAU
Top