Efficient worksheet change vba code

antmol89

New Member
Joined
Mar 29, 2018
Messages
8
Hi all

Does anybody no a way to perform the actions of the following code more efficiently / with less lines of code. As is, I will need to run similar versions of it over 500 times (Will this cause a speed issue?).

Each version of the code will look for a different word (72 in total) in cell "I24" (highlighted below). The code will then perform an Index and Match on different sheets (72 in total) based on the previous word identified.

My second question is whether I can put two words in the IF equation (i.e., IF(I24=UTG and I25=Four,Index....)?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)


 [COLOR=#000000] If Target.Address = "$I$25" Then
        Range("N16").Value = [IF(I24="UTG o",INDEX(UTG!B3:B171,MATCH(I23,UTG!A3:A171,0)),"")]
  End If


  If Target.Address = "$I$25" Then
        Range("N18").Value = [IF(I24="UTG o",INDEX(UTG!C3:C171,MATCH(I23,UTG!A3:A171,0)),"")]
  End If


  If Target.Address = "$I$25" Then
        Range("N20").Value = [IF(I24="UTG o",INDEX(UTG!D3:D171,MATCH(I23,UTG!A3:A171,0)),"")]
  End If


  If Target.Address = "$I$25" Then
        Range("N22").Value = [IF(I24="UTG o",INDEX(UTG!E3:E171,MATCH(I23,UTG!A3:A171,0)),"")]
  End If


End Sub[/COLOR]
Really appreciate anybody who can help on this one!

Cheers!
 
Last edited by a moderator:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
IF(I24=UTG and I25=Four would usually be written like IF(AND(I24="UTG",I25="Four" etc
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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