Results 1 to 6 of 6

Improving VBA Loop speed

Threaded View

  1. #1
    Registered User
    Join Date
    11-25-2019
    Location
    Korea
    MS-Off Ver
    2010
    Posts
    12

    Improving VBA Loop speed

    Hello all,

    I am trying to improve the speed of my loop macro because my loop macro is very slow to run a large database, over 3000 rows.
    Is there any way to improve my loop macro? I have attached an example.

    I would be appreciated with your help. Thanks.


    Sub Sample()
    
    Dim lastRow As Integer
    'Dim SourceWB As Workbook: Set PAASourceWB = Workbooks.Open("C:\Users\user\Desktop\Src.xlsx")
        'SourceWB.Sheets("Src").Copy Before:=ThisWorkbook.Sheets("PROCESS")
        'SourceWB.Close
    Dim TargetWB As Workbook: Set PAATargetWB = Workbooks.Open("C:\Users\user\Desktop\VBA_Help_Sample.xlsm")
    Dim lRowCount As Integer, i As Integer
    Dim v As String
    v = "1st_Run"
    
    Application.ScreenUpdating = False
    Application.Calculation = xlAutomatic
    
    Sheets("Tgt").Range("B6:XFD1048576").Delete Shift:=xlUp
    
    With ThisWorkbook
    lRowCount = Sheets("Src").Cells(Rows.Count, 1).End(xlUp).Row
        For i = 1 To lRowCount
            .Sheets("PROCESS").Range("i_Num") = i
            .Sheets("PROCESS").Range("B6:H6").Value = .Sheets("Src").Range("A" & i + 1 & ":G" & i + 1).Value
            .Sheets("Tgt").Range("F" & i + 5 & ":J" & i + 5).Value = .Sheets("PROCESS").Range("D4:H4").Value
            .Sheets("Tgt").Range("B" & i + 5) = v
            .Sheets("Tgt").Range("C" & i + 5) = .Sheets("PROCESS").Range("F3").Value
            .Sheets("Tgt").Range("D" & i + 5) = .Sheets("PROCESS").Range("C6").Value
            .Sheets("Tgt").Range("E6:E" & i + 5).Formula = _
            "=CONCAT(B6," & Chr(34) & "|" & Chr(34) & ",C6," & Chr(34) & "|" & Chr(34) & ",D6)"
        Next i
    End With
    
    Application.ScreenUpdating = True
    Application.Calculation = xlManual
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Improving speed of creating pdf
    By karolina1406 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2020, 04:16 AM
  2. Help with if/for loop [speed up file operation loop]
    By dr.doom76 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-22-2018, 02:45 AM
  3. Improving the speed of a loop through a date range
    By NorthUnit in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-10-2015, 06:15 PM
  4. [SOLVED] Speed Up Loop in VBA
    By PY_ in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-19-2013, 08:57 AM
  5. Improving calculation speed of a sheet utilizing many "sumifs"
    By blademan88 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-10-2013, 02:21 PM
  6. Improving Speed of Index and Match Functions
    By hazza147 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-30-2010, 01:05 PM
  7. improving speed and efficiency
    By wishmaker in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-14-2010, 11:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1