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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
17,251
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,122,246
Messages
5,595,044
Members
413,963
Latest member
teggl97

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
Top