Hey guys, here's a part of my code that contains putting these formulas in 7 different columns for i amount of rows (i = ~210,000). At the end of the code, I copy the range and paste as values to get rid of the formulas, but keep the values.
It works, but the problem is that it REALLY slows down my macro. I'm wondering if anyone could look at this and think of a way to optimize it / make it more efficient?
Any tips would be great!
It works, but the problem is that it REALLY slows down my macro. I'm wondering if anyone could look at this and think of a way to optimize it / make it more efficient?
Any tips would be great!
Code:
[COLOR=#333333]Sub Formulas()
[/COLOR]Last = DataSheet.Range("A1048576").End(xlUp).Row
For i = 1 To Last - 1
DataSheet.Cells(i + 1, 5).Value = "=INDEX(Table2[Category],MATCH(MID(Data!C" & i + 1 & ",4,3),Table2[Abbreviation],0))"
DataSheet.Cells(i + 1, 6).Value = "=LEFT(Data!C" & i + 1 & ",3)"
DataSheet.Cells(i + 1, 7).Value = "=INDEX(Table2[Department],MATCH(MID(Data!C" & i + 1 & ",4,3),Table2[Abbreviation],0))"
DataSheet.Cells(i + 1, 8).Value = "=MID(Data!C" & i + 1 & ",7,3)"
DataSheet.Cells(i + 1, 9).Value = "=""20"" & RIGHT(Data!C" & i + 1 & ",2)"
DataSheet.Cells(i + 1, 10).Value = "=VLOOKUP(Data!B" & i + 1 & ",Locations,3,0)"
DataSheet.Cells(i + 1, 11).Value = "=VLOOKUP(Data!B" & i + 1 & ",Locations,4,0)"
Next i
[COLOR=#333333]End Sub[/COLOR]