autosum

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

TrustPilot

starstarstarstarstar Excellent

  • Home
  • Courses
  • Promotions
  • Schedule
  • Formats
  • Our Clients

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » AutoSum

AutoSum

resolvedResolved · Medium Priority · Version 2007

Ross has attended:
Excel VBA Intro Intermediate course

AutoSum

Hi

After running a macro i want to put a sum at the bottom but the problem is that the area could change each time

the current formula is

range("D7").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(R[-12]C:R[-1]C)"

This will only sum 12 Rows. The amount of row will vary
how can tell how many rows it needs to Sum.

RE: AutoSum

Hi Ross, have a look in our commented code for how we used currentregion.rows.count and then use that to cope with your fluctuating numbers of rows.

Hope this helps,

Anthony

Fri 2 Mar 2012: Automatically marked as resolved.


 

Excel tip:

How to select certain data in an Excel 2010 workbook

If you want to select the correct data set in a page full of data, the most accurate and efficient way of doing this is to use the ''Shift and Click'' technique.

For example: If you want to select all data in cells A2 to E10, then click on cell A2, hold down the Shift key and click on cell E10 and all the data you want to see is highlighted.

Keep holding down the Shift key and you can move from cell E10 to any other cell in the spreadsheet.

View all Excel hints and tips


Server loaded in 0.07 secs.