summing cells on a different sheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
I am using the following VBA to sum several discontiguous cells from Sheet
1, and placing the total on Sheet 2. Is there a more efficient way of doing
this without getting too into coding? I am not a strong coder adn want to
avoid it if I can.

Range("E10").Value = Worksheets("Actual vs Budget").Range("C36") +
Worksheets("Actual vs Budget").Range("E36") + Worksheets("Actual vs
Budget").Range("G36") + Worksheets("Actual vs Budget").Range("i36")
 
you can arrage the codes as following:
With Worksheets("Actual vs Budget")
Range("E10").Value = .Range("C36") + .Range("E36") + .Range("G36") +
..Range("i36")
End With
 
You can use this formula in Range("E10").

=SUM('Actual vs Budget'!C36,'Actual vs Budget'!E36,'Actual vs
Budget'!G36,'Actual vs Budget'!I36)

If want the code, turn on the macro recorder and record the formula for
Range("E10"). You can modify to suit.

Regards,

Alan
 
Try this:
Range("E10").Value = WorkSheetFunction.Sum(Worksheets("Actual vs
Budget").Range("C36, E36, G36, I36")
 
Range("E10").Value = WorkSheetFunction.Sum(Worksheets("Actual vs
Budget").Range("C36, E36, G36, I36"))

Keep forgetting to count the parentheses. :)
 
Third time is a charm:

Range("E10").Value = Application.WorkSheetFunction.Sum(Worksheets("Actual vs
Budget").Range("C36, E36, G36, I36"))

OK, that's it! This time I looked before I posted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top