VBA Code take too much time

faraz502

Board Regular
Joined
Mar 26, 2014
Messages
127
Office Version
  1. 2016
Platform
  1. Windows
I am Using B/M code in VBA excel but it's too much time.

This Formula In G33:J33 Cell
=IFERROR(INDEX('INV LOG'!$B:$B,SMALL(IF($E$8='INV LOG'!$J:$J,ROW('INV LOG'!$J:$J)-ROW('INV LOG'!$J$1)+1),$X1)),"")


Range("G33:J33").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Range("G33").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi,

Do below changes:

VBA Code:
'Add these lines
Application.screenupdating = false
Application.Calculation = xlCalculationManual
'****

Range("G33:J33").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.FillDown
Selection.Copy
Range("G33").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

'Add these lines
Application.ScreenUpdating = true
Application.Calculation = xlCalculationAutomatic
'****
 
Upvote 0
What about
VBA Code:
  Application.Calculation = xlCalculationManual
    Range("G33:J33").Select
    With Range(Selection, Selection.End(xlDown))
        .FillDown
        Application.Calculation = xlCalculationAutomatic
        .Value = .Value
    End With
 
Upvote 0
The problem is not the VBA .. it is your formula ... using array tests on full column ranges is going to be slow to fill down whether you try manually or use VBA. Do you really need to reference full columns (1,048,576 cells)?
 
Upvote 0
it will be much faster if you can have a defined range and get rid of .select
 
Upvote 0
show the whole subroutine
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,558
Members
449,038
Latest member
Guest1337

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