Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6831271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:43:05+00:00 2026-05-26T22:43:05+00:00

I know VBA in Excel isn’t the quickest of things – but I need

  • 0

I know VBA in Excel isn’t the quickest of things – but I need the most efficient (i.e. quickest) way to loop through a large sample of rows.

Currently I have:

For Each c In Range("$A$2:$A$" & Cells(Rows.count, "A").End(xlUp).row
    ' do stuff
Next c

The ‘do stuff’ includes insert a row here and there (so I need to keep the dynamic lookup of the range.)

Any ideas (looking at 10,000 rows+)?

EDIT
I am already using

Application.ScreenUpdating = False
Application.Calculation = xlManual
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:43:05+00:00Added an answer on May 26, 2026 at 10:43 pm

    If you are just looping through 10k rows in column A, then dump the row into a variant array and then loop through that.

    You can then either add the elements to a new array (while adding rows when needed) and using Transpose() to put the array onto your range in one move, or you can use your iterator variable to track which row you are on and add rows that way.

    Dim i As Long
    Dim varray As Variant
    
    varray = Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row).Value
    
    For i = 1 To UBound(varray, 1)
        ' do stuff to varray(i, 1)
    Next
    

    Here is an example of how you could add rows after evaluating each cell. This example just inserts a row after every row that has the word “foo” in column A. Not that the “+2” is added to the variable i during the insert since we are starting on A2. It would be +1 if we were starting our array with A1.

    Sub test()
    
    Dim varray As Variant
    Dim i As Long
    
    varray = Range("A2:A10").Value
    
    'must step back or it'll be infinite loop
    For i = UBound(varray, 1) To LBound(varray, 1) Step -1
        'do your logic and evaluation here
        If varray(i, 1) = "foo" Then
           'not how to offset the i variable 
           Range("A" & i + 2).EntireRow.Insert
        End If
    Next
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new with VBA Excel and i only know the things as far
I know this isn't directly programming related, but at the same time... Mac Excel
I have the same issue as in Excel VBA: Parsed JSON Object Loop but
Does anyone know the fastest way to get data from and Excel table (VBA
I have been programming 10 years, mostly in vba and vb.net but I know
Excel VBA: I am trying to get to some activex option buttons through the
I would like to know if using VBA I can compare two similar excel
So hopefully that topic isn't too confusing, but basically using VBA within Outlook I
I need to add a datepicker in Excel in a custom vba form. I
I would like to use VBA in Excel 2007 to step through about 500

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.