lookup with vba in private sub

thespardian

Board Regular
Joined
Aug 31, 2012
Messages
119
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hi there!
@Fluff please.
Sheet 2 may be called Database. I entered the data over here and the Sheet3 may be called result sheet where I have entered the following formulas in column A and column B respectively.

Formula is Column A (on Sheet3)
=IF('SH3'!$C3="","",INDEX('SH2'!$C$3:$C$10000,MATCH('SH3'!$C3,'SH2'!$A$3:$A$10000,0)))

Formula in Column B (on Sheet3)
=IF('SH3'!$C3="","",INDEX('SH2'!$D$3:$D$10000,MATCH('SH3'!$C3,'SH2'!$A$3:$A$10000,0)))

There is a lot of data in Sheet2, The above formula is making it slow. Therefore I want to replace these formulas with a vb code that works with selection change event. Any help will be highly appreciated.
Sh2.png
Sh3.png
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Thanks a lot for the guidance @bebo021999

This the database sheet (Sheet2)
book4.xlsm
ABCD
2RefDateProject#Head
3398 25.08.2009.11.20217620p
4399 25.08.2010.11.20217620c
5421 08.09.2011.11.20217620s
6422 08.09.2012.11.20217620es
7423 08.09.2013.11.20217620l
8400 26.08.2009.11.20217620st
SH2


And this is the result (Sheet3)
book4.xlsm
ABC
2Project#cHeadRef
37620p398 25.08.20
47620c399 25.08.20
57620s421 08.09.20
67620es422 08.09.20
77620l423 08.09.20
87620st400 26.08.20
9  
SH3
Cell Formulas
RangeFormula
A3:A9A3=IF('SH3'!$C3="","",INDEX('SH2'!$C$3:$C$10000,MATCH('SH3'!$C3,'SH2'!$A$3:$A$10000,0)))
B3:B9B3=IF('SH3'!$C3="","",INDEX('SH2'!$D$3:$D$10000,MATCH('SH3'!$C3,'SH2'!$A$3:$A$10000,0)))
Named Ranges
NameRefers ToCells
'SH2'!_FilterDatabase='SH2'!$A$3:$G$7620A3:B9
Cells with Data Validation
CellAllowCriteria
C3:C9List='SH2'!$A$3:$A$26
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,195
Members
449,072
Latest member
DW Draft

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