Speed up Macro

Bars03

New Member
Joined
May 12, 2015
Messages
18
Hi

I am using the below code to assist in creating a journal. It is assigning a Nominal code to use based on certain criteria. The problem I have is that there can be several thousand lines on the spreadsheet and it is proving very time consuming to run.

Is there any alternative code that I can use to speed up the process?

Thanks on Advance.



Sub UpdateTOrigBankAcc()
'
' UpdateTOrigBankAcc Macro
'

'

Application.ScreenUpdating = False


Dim Lastrow As String

Sheets("Transactions Orig").Select

Range("A1").Select
Selection.End(xlDown).Select
Lastrow = ActiveCell.Row


Range("M2").Select
Selection.FormulaArray = _
"=INDEX(Identifier!C[-8],MATCH(1,(Identifier!C[-12]='Transactions Orig'!RC[-12])*(Identifier!C[-11]='Transactions Orig'!RC[-9]),0))"

Range("M3").Select
Selection.Copy
Range("M2:M" & Lastrow).Select

ActiveSheet.Paste
Columns("M:M").Select
Selection.Copy
Range("M1").Select
Selection.PasteSpecial Paste:=xlPasteValues


Application.ScreenUpdating = True



End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi Bars03,

The code looks clean. I don't think the Macro is the slow part. I think it is the array formula in column M is the slow part. Here are some options that _might_ speed it up.
1) (re) arrange you data in "Identifier" so the equation is simpler
2) faster computer (right....)
3) It is a long shot, but look at reading "Transactions Orig" and "Identifier" into a VBA Array then process the results and past back the array. If you go this route, be sure to find and use the code to paste the entire array in one shot. If you do this cell by cell, you will find it to be very slow. The Excel functions run "fast" compared to VBA - given the equation / functions are simple. There is a point in time where a VBA function becomes faster then native Excel functions, but that break point is only validated through tests.

Tubal
 
Upvote 0
You don't need to select sheets or cells to perform actions.

Code:
Sub UpdateTOrigBankAcc()

' UpdateTOrigBankAcc Macro




Application.ScreenUpdating = False


Dim Lastrow As String


With Sheets("Transactions Orig")


    Lastrow = .Cells(Rows.Count, 1).End(xlUp).Row


    With .Range("M2:M" & Lastrow)
        .FormulaArray = "=INDEX(Identifier!C[-8],MATCH(1,(Identifier!C[-12]='Transactions Orig'!RC[-12])*(Identifier!C[-11]='Transactions Orig'!RC[-9]),0))"
        .Formula = .Value
    End With
End With




Application.ScreenUpdating = True






End Sub
 
Upvote 0

Forum statistics

Threads
1,203,242
Messages
6,054,349
Members
444,717
Latest member
melindanegron

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