Results 1 to 5 of 5

Excel VBA - Condense multiple variable transfer code

Threaded View

  1. #1
    Registered User
    Join Date
    11-28-2012
    Location
    Globe, Arizona
    MS-Off Ver
    Excel 2010
    Posts
    19

    Excel VBA - Condense multiple variable transfer code

    Hi, I would like some help to condense this please, it works but…
    1- I would like to see it done cleaner and better, I’ve tried to no avail
    2- And because I have nine other worksheets to add to the code

    Sub RollUp()
    
    Application.ScreenUpdating = False
    
        Sheets("Conrad").Activate
    n = Cells(Rows.Count, "E").End(xlUp).Row
        Sheets("Roll Up").Activate
    k = Application.WorksheetFunction.Max(1, Cells(Rows.Count, "AG").End(xlUp).Row + 1)
        Sheets("Conrad").Activate
    For i = n To 1 Step -1
        If Cells(i, "E").Value = "MOVED DATE" Then
            Cells(i, "E").EntireRow.Copy Sheets("Roll Up").Cells(k, 1)
            k = k + 1
        End If
    Next
    
        Sheets("Conrad").Activate
    n = Cells(Rows.Count, "E").End(xlUp).Row
        Sheets("Roll Up").Activate
    k = Application.WorksheetFunction.Max(1, Cells(Rows.Count, "AG").End(xlUp).Row + 1)
        Sheets("Conrad").Activate
    For i = n To 1 Step -1
        If Cells(i, "E").Value = "Pending" Then
            Cells(i, "E").EntireRow.Copy Sheets("Roll Up").Cells(k, 1)
            k = k + 1
        End If
    Next
    
        Range("B2").Select
        ActiveCell.FormulaR1C1 = "1"
    LastRow = ActiveSheet.UsedRange.Rows.Count
    Range("B2").AutoFill Destination:=Range("B2:B" & LastRow), Type:=xlFillSeries
        Sheets("Roll Up").Activate
    Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files
    Last edited by Isacc; 11-29-2012 at 01:50 PM. Reason: to wrap code text, per rule #3

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