Results 1 to 3 of 3

VBA Hangs after paste!!

Threaded View

  1. #1
    Registered User
    Join Date
    02-18-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    26

    VBA Hangs after paste!!

    Hi, could somebody please take a look at the code below and tell me what am i doing wrong?

    I first copy 3 different columns from a sheet to a sheet called "Temp".
    There i used advanced filter to copy the unique set of rows (Till then it runs just fine!)

    Then i activate another sheet and try to paste the data. It is now that the VBA hangs for good 5 minutes! I am not sure what am i doing wrong.. I don't understand what VBA could be doing for such a long time! please guide me!

        With Application
            .ScreenUpdating = False
            .Calculation = xlManual
        End With
     
        Dim AID_ColNum As Long
        Dim Loc_ColNum As Long
        Dim Date_ColNum As Long
        Dim data_ccount As Integer
        Dim data_rcount As Integer
        Dim i As Integer
     
        Sheets("Additional Columns").Activate
     
        data_rcount = 0
        data_ccount = 0
     
        data_rcount = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        data_ccount = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
     
        For i = 1 To data_ccount
            If (Cells(1, i).Value = "Associate") Then
                AID_ColNum = i
            End If
            If (Cells(1, i).Value = "As Of Data") Then
                Date_ColNum = i
            End If
            If (Cells(1, i).Value = "Location") Then
                Loc_ColNum = i
            End If
        Next
     
        Sheets("Additional Columns").Activate
        Range(Change2Letter(AID_ColNum) & "1:" & Change2Letter(AID_ColNum) & data_rcount).Select
        Selection.Copy
        Sheets("Temp").Activate
        Range("A1").Activate
        ActiveSheet.Paste
        Application.CutCopyMode = False
     
        Sheets("Additional Columns").Activate
        Range(Change2Letter(Loc_ColNum) & "1:" & Change2Letter(Loc_ColNum) & data_rcount).Select
        Selection.Copy
        Sheets("Temp").Activate
        Range("IV1").End(xlToLeft).Offset(0, 1).Activate
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
     
        Sheets("Additional Columns").Activate
        Range(Change2Letter(Date_ColNum) & "1:" & Change2Letter(Date_ColNum) & data_rcount).Select
        Selection.Copy
        Sheets("Temp").Activate
        Range("IV1").End(xlToLeft).Offset(0, 1).Activate
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Selection.NumberFormat = "mmm-yy"
        'ActiveSheet.Paste
        Application.CutCopyMode = False
     
        Sheets("Temp").Activate
     
        data_rcount = 0
        data_ccount = 0
     
        'data_rcount = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        'data_ccount = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
     
        data_rcount = ActiveSheet.UsedRange.Rows.Count
        data_ccount = ActiveSheet.UsedRange.Columns.Count
     
        'MsgBox (data_rcount)
        'MsgBox (data_ccount)
    '
        Range("A1:" & Change2Letter(data_ccount) & data_rcount).AdvancedFilter Action:=xlFilterInPlace, Unique:=True
        Cells.Select
        Selection.Copy
     
        'Selection.AutoFilter
        'Selection.AutoFilter
     
        Sheets("OffshoreOnsite_Hidden").Activate
        Range("A1").Select
        Selection.PasteSpecial
        ActiveSheet.Range("A1").Select
        Application.CutCopyMode = False
    Last edited by VBA Noob; 03-05-2009 at 01:45 PM.

Thread Information

Users Browsing this Thread

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

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