Need help editing VBA to for a range that changes daily

%3CLINGO-SUB%20id%3D%22%5C%26quot%3Blingo-sub-3163538%5C%26quot%3B%22%20slang%3D%22%5C%26quot%3Ben-US%5C%26quot%3B%22%3ENeed%20help%20editing%20VBA%20to%20for%20a%20range%20that%20changes%20daily%26lt%3B%5C%2Flingo-sub%26gt%3B%3CLINGO-BODY%20id%3D%22%5C%26quot%3Blingo-body-3163538%5C%26quot%3B%22%20slang%3D%22%5C%26quot%3Ben-US%5C%26quot%3B%22%3E%3CP%3EHello!%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3EI%20am%20needing%20some%20assistance!%20Here's%20the%20situation%2C%20At%20work%20everyday%2C%20someone%20in%20my%20team%20pulls%20the%20previous%20days%20ACH%20payments%20received%20and%20adds%20it%20to%20that%20days%20sheet%20in%20the%20cuirrent%20month's%20excel%20file.%20To%20save%20time%20and%20keep%20a%20consistent%20look%20from%20day%20to%20day%2C%20I%20built%20a%20macro%20to%20make%20the%20data%20more%20pleasing%20to%20the%20eye%20and%20easier%20to%20read.%20It%20worked%20great%20until%20the%20next%20day%20came%20about%20and%20we%20had%20more%20payments%20come%20in%2C%20meaning%20more%20rows%20of%20data%20so%20this%20is%20what%20the%20finished%20product%20comes%20out%20as%3A%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22%5C%26quot%3Blia-inline-image-display-wrapper%22%20lia-image-align-center%3D%22%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Fgxcuf89792%2F%5C%26quot%3Bhttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F348073iD75DB00D0A389574%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%5C%26quot%3B%22%20role%3D%22%5C%26quot%3Bbutton%5C%26quot%3B%22%20title%3D%22vbatotal.png%22%20alt%3D%22%5C%26quot%3Bvbatotal.png%5C%26quot%3B%22%20%2F%3E%26lt%3B%5C%2Fspan%26gt%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EHow%20do%20I%20change%20the%20VBA%20so%20that%20the%20range%20of%20data%20isn't%20preset%20only%20to%20A17%3A%20G17%3F%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3EAlso%2C%20I'm%20not%20sure%20if%20this%20would%20be%20included%20or%20not%20but%20I%20need%20to%20put%20a%20total%20row%20at%20the%20end%20and%20total%20up%20the%20payments%20in%20column%20E.%26nbsp%3B%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3EThis%20is%20what%20the%20VBA%20looks%20like%20for%20the%20macro%20I%20built%2C%20Any%20assistance%20is%20greatly%20appreciated!!!%20Thank%20youi!!%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3ESub%20MAKEemPRETTY()%3CBR%20%2F%3E'%3CBR%20%2F%3E'%20MAKEemPRETTY%20Macro%3CBR%20%2F%3E'%20Formats%20the%20list%20of%20daily%20EFT's%20to%20be%20visually%20appealing%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E'%20Keyboard%20Shortcut%3A%20Ctrl%2Bm%3CBR%20%2F%3E'%3CBR%20%2F%3ECells.Select%3CBR%20%2F%3ECells.EntireColumn.AutoFit%3CBR%20%2F%3ERange(%22E17%22).Select%3CBR%20%2F%3EActiveCell.FormulaR1C1%20%3D%20%22%3DSUM(R%5B-13%5DC%3AR%5B-1%5DC)%22%3CBR%20%2F%3EColumns(%22E%3AE%22).Select%3CBR%20%2F%3ERange(%22E3%22).Activate%3CBR%20%2F%3ESelection.Style%20%3D%20%22Currency%22%3CBR%20%2F%3EColumns(%22A%3AA%22).Select%3CBR%20%2F%3ERange(%22A3%22).Activate%3CBR%20%2F%3ESelection.NumberFormat%20%3D%20%22mm%2Fdd%2Fyyyy%22%3CBR%20%2F%3ERange(%22A17%3AD17%2CF17%3AG17%22).Select%3CBR%20%2F%3ERange(%22F17%22).Activate%3CBR%20%2F%3EWith%20Selection%3CBR%20%2F%3E.HorizontalAlignment%20%3D%20xlCenter%3CBR%20%2F%3E.VerticalAlignment%20%3D%20xlBottom%3CBR%20%2F%3E.WrapText%20%3D%20False%3CBR%20%2F%3E.Orientation%20%3D%200%3CBR%20%2F%3E.AddIndent%20%3D%20False%3CBR%20%2F%3E.IndentLevel%20%3D%200%3CBR%20%2F%3E.ShrinkToFit%20%3D%20False%3CBR%20%2F%3E.ReadingOrder%20%3D%20xlContext%3CBR%20%2F%3E.MergeCells%20%3D%20False%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3ESelection.Merge%3CBR%20%2F%3ERange(%22A%3AB%2CF%3AG%22).Select%3CBR%20%2F%3ERange(%22F3%22).Activate%3CBR%20%2F%3EWith%20Selection%3CBR%20%2F%3E.HorizontalAlignment%20%3D%20xlGeneral%3CBR%20%2F%3E.VerticalAlignment%20%3D%20xlBottom%3CBR%20%2F%3E.WrapText%20%3D%20False%3CBR%20%2F%3E.Orientation%20%3D%200%3CBR%20%2F%3E.AddIndent%20%3D%20False%3CBR%20%2F%3E.IndentLevel%20%3D%200%3CBR%20%2F%3E.ShrinkToFit%20%3D%20False%3CBR%20%2F%3E.ReadingOrder%20%3D%20xlContext%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3EWith%20Selection%3CBR%20%2F%3E.HorizontalAlignment%20%3D%20xlCenter%3CBR%20%2F%3E.VerticalAlignment%20%3D%20xlBottom%3CBR%20%2F%3E.WrapText%20%3D%20False%3CBR%20%2F%3E.Orientation%20%3D%200%3CBR%20%2F%3E.AddIndent%20%3D%20False%3CBR%20%2F%3E.IndentLevel%20%3D%200%3CBR%20%2F%3E.ShrinkToFit%20%3D%20False%3CBR%20%2F%3E.ReadingOrder%20%3D%20xlContext%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3ERange(%22A17%3AG17%22).Select%3CBR%20%2F%3EWith%20Selection.Interior%3CBR%20%2F%3E.Pattern%20%3D%20xlSolid%3CBR%20%2F%3E.PatternColorIndex%20%3D%20xlAutomatic%3CBR%20%2F%3E.Color%20%3D%2013434624%3CBR%20%2F%3E.TintAndShade%20%3D%200%3CBR%20%2F%3E.PatternTintAndShade%20%3D%200%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3ERange(%22A17%3AG17%22).Select%3CBR%20%2F%3ESelection.Font.Bold%20%3D%20True%3CBR%20%2F%3ERange(%22A17%3AD17%22).Select%3CBR%20%2F%3EActiveCell.FormulaR1C1%20%3D%20%22TOTAL%22%3CBR%20%2F%3ERange(%22A17%3AD17%22).Select%3CBR%20%2F%3EWith%20Selection%3CBR%20%2F%3E.HorizontalAlignment%20%3D%20xlRight%3CBR%20%2F%3E.VerticalAlignment%20%3D%20xlBottom%3CBR%20%2F%3E.WrapText%20%3D%20False%3CBR%20%2F%3E.Orientation%20%3D%200%3CBR%20%2F%3E.AddIndent%20%3D%20False%3CBR%20%2F%3E.IndentLevel%20%3D%200%3CBR%20%2F%3E.ShrinkToFit%20%3D%20False%3CBR%20%2F%3E.ReadingOrder%20%3D%20xlContext%3CBR%20%2F%3E.MergeCells%20%3D%20True%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3ERange(%22A1%3AG17%22).Select%3CBR%20%2F%3ERange(%22F17%22).Activate%3CBR%20%2F%3ESelection.Borders(xlDiagonalDown).LineStyle%20%3D%20xlNone%3CBR%20%2F%3ESelection.Borders(xlDiagonalUp).LineStyle%20%3D%20xlNone%3CBR%20%2F%3EWith%20Selection.Borders(xlEdgeLeft)%3CBR%20%2F%3E.LineStyle%20%3D%20xlContinuous%3CBR%20%2F%3E.ColorIndex%20%3D%200%3CBR%20%2F%3E.TintAndShade%20%3D%200%3CBR%20%2F%3E.Weight%20%3D%20xlThin%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3EWith%20Selection.Borders(xlEdgeTop)%3CBR%20%2F%3E.LineStyle%20%3D%20xlContinuous%3CBR%20%2F%3E.ColorIndex%20%3D%200%3CBR%20%2F%3E.TintAndShade%20%3D%200%3CBR%20%2F%3E.Weight%20%3D%20xlThin%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3EWith%20Selection.Borders(xlEdgeBottom)%3CBR%20%2F%3E.LineStyle%20%3D%20xlContinuous%3CBR%20%2F%3E.ColorIndex%20%3D%200%3CBR%20%2F%3E.TintAndShade%20%3D%200%3CBR%20%2F%3E.Weight%20%3D%20xlThin%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3EWith%20Selection.Borders(xlEdgeRight)%3CBR%20%2F%3E.LineStyle%20%3D%20xlContinuous%3CBR%20%2F%3E.ColorIndex%20%3D%200%3CBR%20%2F%3E.TintAndShade%20%3D%200%3CBR%20%2F%3E.Weight%20%3D%20xlThin%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3EWith%20Selection.Borders(xlInsideVertical)%3CBR%20%2F%3E.LineStyle%20%3D%20xlContinuous%3CBR%20%2F%3E.ColorIndex%20%3D%200%3CBR%20%2F%3E.TintAndShade%20%3D%200%3CBR%20%2F%3E.Weight%20%3D%20xlThin%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3EWith%20Selection.Borders(xlInsideHorizontal)%3CBR%20%2F%3E.LineStyle%20%3D%20xlContinuous%3CBR%20%2F%3E.ColorIndex%20%3D%200%3CBR%20%2F%3E.TintAndShade%20%3D%200%3CBR%20%2F%3E.Weight%20%3D%20xlThin%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3ERange(%22A5%3AG5%22).Select%3CBR%20%2F%3EWith%20Selection.Interior%3CBR%20%2F%3E.Pattern%20%3D%20xlSolid%3CBR%20%2F%3E.PatternColorIndex%20%3D%20xlAutomatic%3CBR%20%2F%3E.Color%20%3D%2016770559%3CBR%20%2F%3E.TintAndShade%20%3D%200%3CBR%20%2F%3E.PatternTintAndShade%20%3D%200%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3ERange(%22A4%3AG5%22).Select%3CBR%20%2F%3ESelection.Copy%3CBR%20%2F%3ERange(%22A6%3AG16%22).Select%3CBR%20%2F%3ESelection.PasteSpecial%20Paste%3A%3DxlPasteFormats%2C%20Operation%3A%3DxlNone%2C%20_%3CBR%20%2F%3ESkipBlanks%3A%3DFalse%2C%20Transpose%3A%3DFalse%3CBR%20%2F%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3ERange(%22F19%22).Select%3CBR%20%2F%3EColumns(%22F%3AF%22).ColumnWidth%20%3D%2043.29%3CBR%20%2F%3EColumns(%22F%3AF%22).Select%3CBR%20%2F%3ERange(%22F3%22).Activate%3CBR%20%2F%3EWith%20Selection%3CBR%20%2F%3E.HorizontalAlignment%20%3D%20xlCenter%3CBR%20%2F%3E.VerticalAlignment%20%3D%20xlBottom%3CBR%20%2F%3E.WrapText%20%3D%20True%3CBR%20%2F%3E.Orientation%20%3D%200%3CBR%20%2F%3E.AddIndent%20%3D%20False%3CBR%20%2F%3E.IndentLevel%20%3D%200%3CBR%20%2F%3E.ShrinkToFit%20%3D%20False%3CBR%20%2F%3E.ReadingOrder%20%3D%20xlContext%3CBR%20%2F%3EEnd%20With%3CBR%20%2F%3ERange(%22J9%22).Select%3CBR%20%2F%3EEnd%20Sub%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%26lt%3B%5C%2FP%26gt%3B%26lt%3B%5C%2Flingo-body%26gt%3B%3CLINGO-LABS%20id%3D%22%5C%26quot%3Blingo-labs-3163538%5C%26quot%3B%22%20slang%3D%22%5C%26quot%3Ben-US%5C%26quot%3B%22%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%26lt%3B%5C%2Flingo-label%26gt%3B%26lt%3B%5C%2Flingo-labs%26gt%3B%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3C%2FLINGO-SUB%3E
Occasional Visitor

Hello!

I am needing some assistance! Here's the situation, At work everyday, someone in my team pulls the previous days ACH payments received and adds it to that days sheet in the cuirrent month's excel file. To save time and keep a consistent look from day to day, I built a macro to make the data more pleasing to the eye and easier to read. It worked great until the next day came about and we had more payments come in, meaning more rows of data so this is what the finished product comes out as:

vbatotal.png

How do I change the VBA so that the range of data isn't preset only to A17: G17? 

Also, I'm not sure if this would be included or not but I need to put a total row at the end and total up the payments in column E.  

This is what the VBA looks like for the macro I built, Any assistance is greatly appreciated!!! Thank youi!!

 

Sub MAKEemPRETTY()
'
' MAKEemPRETTY Macro
' Formats the list of daily EFT's to be visually appealing

 

' Keyboard Shortcut: Ctrl+m
'
Cells.Select
Cells.EntireColumn.AutoFit
Range("E17").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-13]C:R[-1]C)"
Columns("E:E").Select
Range("E3").Activate
Selection.Style = "Currency"
Columns("A:A").Select
Range("A3").Activate
Selection.NumberFormat = "mm/dd/yyyy"
Range("A17:D17,F17:G17").Select
Range("F17").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("A:B,F:G").Select
Range("F3").Activate
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
Range("A17:G17").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 13434624
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("A17:G17").Select
Selection.Font.Bold = True
Range("A17:D17").Select
ActiveCell.FormulaR1C1 = "TOTAL"
Range("A17:D17").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
Range("A1:G17").Select
Range("F17").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("A5:G5").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 16770559
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("A4:G5").Select
Selection.Copy
Range("A6:G16").Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("F19").Select
Columns("F:F").ColumnWidth = 43.29
Columns("F:F").Select
Range("F3").Activate
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
End With
Range("J9").Select
End Sub

 

 

0 Replies