Shiv, Are you doing homework for a class? or working on someone else's code? or reading a book?
the use of [ ] is called "relative addressing" or using "Relative Addresses" so.. (r[-5]c:r[-1]c) is a range in the CURRENT column (c) and starting 5 rows above to 1 row above the designated cell So, ActiveCell is the currently "Active" Cell. Keep in mind that if you "select" a range of cells, the first is considered "active". Selection.rows.count is the count of currently selected rows. Activecell.offset(selection.rows.count) identifies the cell in the same column as the "Active" cell, but below the last row. (an "offset" of "count" rows) (if you have rows 5-10 selected, you actually have 6 rows selected. the Active cell is in row 5, moving down 6 rows takes you to row 11) In this cell, insert the string: "=sum(r[-" followed by the count of rows, followed by "]c:r[-1]c)" now, in my above example of 6 rows in column A, you're inserting into A11, r[-6] is row 5, the current column is "A" r[-1] is row 10, so the formula evaluates to: "=sum(A5:A10)" the line: Selection.Resize(Selection.Rows.Count + 1).Select changes the selected range to include the new row. Paul ________________________________ From: Shiv Goel <shivyn...@gmail.com> To: excel-macros@googlegroups.com Sent: Wed, February 10, 2010 12:53:42 AM Subject: $$Excel-Macros$$ Need Help Sub SumCol() ActiveCell.Offset(Selection.Rows.Count).Value = _ "=sum(r[-" & Selection.Rows.Count & "]c:r[-1]c)" Selection.Resize(Selection.Rows.Count + 1).Select End Sub What is the meaning of this code -- Shiv Goel 8NBYN060 ICFAI National College,YNR 9416275776 -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 6,700 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 6,700 subscribers worldwide and receive many nice notes about the learning and support from the group.Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe