Hi,
I need a VBA command to go at the end of row, where the data is last & apply an sum function to column F & column G.
Kindly help me on this.
Thanks in Advance
Hi,
I need a VBA command to go at the end of row, where the data is last & apply an sum function to column F & column G.
Kindly help me on this.
Thanks in Advance
Do you mean you need the sum of two columns placed in a cell at the end of a given row?
Hello mohan_rajun,
Here is the VBA macro code to automatically add the Sum formulas to the end of each column.
Adding the Macro![]()
Sub AddSums() Dim LastRow As Long If WorksheetFunction.CountA(Cells) <> 0 Then LastRow = Cells.Find("*", , xlValues, xlWhole, xlByRows, xlPrevious, True).Row Cells(LastRow + 1, "F").Formula = "=SUM($F1:$F$" & LastRow & ")" Cells(LastRow + 1, "G").Formula = "=SUM($G1:$G$" & LastRow & ")" End If End Sub
- Copy the macro above pressing the keys CTRL+C
- Open your workbook
- Press the keys ALT+F11 to open the Visual Basic Editor
- Press the keys ALT+I to activate the Insert menu
- Press M to insert a Standard Module
- Paste the code by pressing the keys CTRL+V
- Make any custom changes to the macro if needed at this time.
- Save the Macro by pressing the keys CTRL+S
- Press the keys ALT+Q to exit the Editor, and return to Excel.
To Run the Macro...
To run the macro from Excel, open the workbook, and press ALT+F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Hi Leith Ross,
Thanks for your timely help..
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks