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
Bookmarks