Problem executing code VBA

sofas

Active Member
Joined
Sep 11, 2022
Messages
468
Office Version
  1. 2019
Platform
  1. Windows
Hello, how can I fix this code or shorten it? It works fine, but it's slow

VBA Code:
Sub TEST()

Dim MT As Worksheet
Set MT = Feuil1
  With MT.Range("F2:F" & MT.Range("a" & Rows.Count).End(3).Row)
      .Formula = "=VLOOKUP(""*""&RC[-1]&""*"",C1:C4,1,0)"
    .Value = .Value
    With MT.Range("G2:G" & MT.Range("a" & Rows.Count).End(3).Row)
     .Formula = "=VLOOKUP(""*""&RC[-2]&""*"",C1:C4,2,0)"
    .Value = .Value
      With MT.Range("H2:H" & MT.Range("a" & Rows.Count).End(3).Row)
      .Formula = "=VLOOKUP(""*""&RC[-3]&""*"",C1:C4,3,0)"
    .Value = .Value
    With MT.Range("I2:I" & MT.Range("a" & Rows.Count).End(3).Row)
      .Formula = "=VLOOKUP(""*""&RC[-4]&""*"",C1:C4,4,0)"
   .Value = .Value
  End With
  End With
  End With
  End With
End Sub
 
Sofas, can you please confirm time measurements done and can you do same measurements with others codes: Yours and mine
The idea is just to understand with method the best :
So far ( for me ) using formulas was the slowest manner
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
No, the implementation was only on a trial version with about 100 rows. I will try all the suggested methods on the original file to see which one is better. Thank you all for the help
 
Upvote 0
I will try all the suggested methods on the original file to see which one is better
Super, and thanks to let's know the score ... just for information.
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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