vlook and match VBA code

rzml

New Member
Joined
Dec 24, 2020
Messages
40
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
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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.
 
Upvote 0
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 ".
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,973
Members
448,933
Latest member
Bluedbw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top