Consulting

Results 1 to 4 of 4

Thread: If Column A ıs Empty and if Column I has a data copy them to Column A ..

  1. #1
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location

    If Column A ıs Empty and if Column I has a data copy them to Column A ..

    Hi , I am using this VBA that check If column A is empty and if column I has data will copy them to column A and my code working very well just the problem is speed . i have about 830000 Row and it take so much time
    is it possible to help me to make it faster

        Dim r As Range
        For Each r In Intersect(Range("A:A"), ActiveSheet.UsedRange)
            If IsEmpty(r) Then
                r.Offset(0, 8).Copy r.Offset(0, 0)
            End If
        Next
    Thanks for your time and help

  2. #2
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    367
    Location
    have you disabled:
    ->worksheet calculation
    -> Events
    -> Screen updating

    ?

    this can make a fairly big difference

    Werafa
    Remember: it is the second mouse that gets the cheese.....

  3. #3
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location
    Thank you so much really useful tips...

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Quote Originally Posted by parscon View Post
    Hi , I am using this VBA that check If column A is empty and if column I has data will copy them to column A and my code working very well just the problem is speed . i have about 830000 Row and it take so much time
    is it possible to help me to make it faster

    Thanks for your time and help
    1. I think you're doing a lot of unnecessary looping

    2. I don't think you need to test the value in column B since even if A and I are both blank, moving a blank to a blank does the same thing as testing


    Option Explicit
    
    Sub test()
        Dim r As Range, c As Range
        
        With ActiveSheet
            On Error Resume Next
            Set r = Intersect(.Columns(1).SpecialCells(xlCellTypeBlanks), .UsedRange)
            For Each c In r.Cells
                c.Value = c.Offset(0, 8).Value
            Next
            On Error GoTo 0
        End With
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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