Results 1 to 2 of 2

Looping Formula Help

Threaded View

leanne2011 Looping Formula Help 08-12-2013, 04:07 AM
watersev Re: Looping Formula Help 08-12-2013, 05:56 AM
  1. #1
    Forum Contributor
    Join Date
    09-06-2011
    Location
    northern ireland
    MS-Off Ver
    Excel 365
    Posts
    180

    Looping Formula Help

    hi

    I need a bit of help - I have a basic code which still needs a bit of work. But the main bit I need a bit of help with is the formula. I need a sum in the Gross pay Column for each row that there is and same for Net pay.

    From the Output test.xlsx file attached:

    The Gross pay is all the yellow columns added together.

    The Net Pay column is the Gross pay from above less all the light blue columns plus the 2 green columns.

    Here is the main code:

    
    Sub stest()
    
     
     MFile = ActiveWorkbook.Name
        Application.ScreenUpdating = False
    proceed:
        WeeklyFN = Application.GetOpenFilename(fileFilter:="All files (*.*), *.*", Title:="Please open the excel report generated from PRE")
        If WeeklyFN = "" Then
        MsgBox "You have not selected a file."
        GoTo proceed
        Else
        Workbooks.Open Filename:=WeeklyFN
        WeeklyFN = ActiveWorkbook.Name
    End If
    
    Range("a2").Select
        Cells.Find(What:="Grand Summaries", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
        Selection.Delete
        Selection.Clear
        
        'get row count
        Range("A1").Select
        Selection.End(xlDown).Select
        rownumber = ActiveCell.Row
        
        'fill in zero's for blank cells
        Range("C1").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Replace What:="", Replacement:="0.00", LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
        Cells.Select
        Cells.EntireColumn.AutoFit
        Range("A1").Select
        Range("C2").Select
        Range(Selection, Selection.End(xlDown)).Select
        Range(Selection, Selection.End(xlToRight)).Select
        Selection.NumberFormat = "0.0"
        Selection.NumberFormat = "0.00"
        Cells.Select
        With Selection.Font
            .Name = "Georgia"
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        Cells.Select
        Cells.EntireColumn.AutoFit
        Range("B1").Select
        Rows("2:2").Select
        ActiveWindow.FreezePanes = False
        ActiveWindow.FreezePanes = True
        ActiveWindow.SmallScroll Down:=-3
        Range("B1").Select
        Selection.End(xlToRight).Select
        Selection.End(xlDown).Select
        Range("AJ73").Select
        ActiveCell.FormulaR1C1 = "=SUM(R[-71]C:R[-1]C)"
        Range("AI73").Select
        Range(Selection, Selection.End(xlToLeft)).Select
        Range("A73:AI73").Select
        Range("AI73").Activate
        Selection.FormulaR1C1 = "=SUM(R[-71]C:R[-1]C)"
        Range("AH73").Select
        Range("A1").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.End(xlDown).Select
        Selection.ClearContents
        Range("B73").Select
        Selection.ClearContents
        ActiveCell.FormulaR1C1 = "Grand Totals"
        Rows("73:73").Select
        Selection.Font.Bold = True
        Selection.NumberFormat = "0.00"
        Cells.Select
        Cells.EntireColumn.AutoFit
        Range("A1").Select
        Cells.Select
        With Selection.Font
            .Name = "Georgia"
            .Size = 8
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
        End With
        
        Range("A1").Select
        Filesavename = Application.GetSaveAsFilename(fileFilter:="xlsx (Excel Workbook) (*.xlsx), *.xlsx", Title:="Please save the excel spreadsheet")
      If Filesavename <> "" Then
       
      
        ActiveWorkbook.SaveAs Filename:=Filesavename
           
       
    
    End If
    
     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. [SOLVED] Looping an index transposing formula
    By poetgirl916 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-22-2013, 01:52 PM
  2. User Input Checking & Formula Looping
    By flebber in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-12-2010, 09:12 PM
  3. Looping through cells setting a formula
    By JonPugh in forum Excel General
    Replies: 1
    Last Post: 01-08-2010, 12:04 PM
  4. Looping of repeatitive formula
    By Chetan Chauhan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-09-2009, 03:03 AM
  5. creating a looping formula between different spreadsheets
    By Jon Buonocore in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 03-27-2006, 11:35 PM

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