0

I'm working on Excel 2007 macros where I have to select data in first column from range 0 to 300 , 300 to 600, 600 to 900 and so on incrementing 300.
Where the values of column H with respect to 0 to 300 should be sum and transfer to sheet2 and sum of values of 300 to 600 of H column transferred to sheet2 for all such cases.

I wish to create a button in Excel macro by pressing it transfer all data summing to sheet2. The picture below describes better about my case.

Picture of my problem case

8
  • (1) Why don't you use formulas? There is no need for VBA I think. Formulas are Excel's strength this is what it was designed for. (2) If you really need VBA then please show the code you already have and ask a specific question to it, because this is not a free code writing service. (3) Also try to describe it more detailed, your question is not very clear/exactly. You even didn't ask a question. Commented Sep 6, 2017 at 8:52
  • thank you for replying formula is enough for me but i have to add only specific columns for each cases how to do in excel formula and transfer to next sheet Commented Sep 6, 2017 at 8:56
  • Sorry but your question is very unclear. You need to be much more specific to get a useful answer. And you need to show what you already have, because we will not do all the work for you. People are here to help you to solve your issues on your own. Commented Sep 6, 2017 at 8:58
  • column h2 to h8 and h9 to h10 and h11 to h13 should be automatically selected and sum is it possible to do for such case and transfer to sheet 2 Commented Sep 6, 2017 at 8:59
  • Then use formulas =SUM(Sheet1!H2:H8) and =SUM(Sheet1!H9:H10) and =SUM(Sheet1!H11:H13) in sheet 2 Commented Sep 6, 2017 at 9:00

1 Answer 1

1

This can be done with the formula SUMIFS

=SUMIFS(Sheet1!H:H,Sheet1!A:A,">=0",Sheet1!A:A,"<300")

This formula calculates the sum of column H,
where the value in column A is between 0 and 299 (>=0 and <300)

=SUMIFS(Sheet1!H:H,Sheet1!A:A,">=300",Sheet1!A:A,"<600")

This formula calculates the sum of column H,
where the value in column A is between 300 and 599 (>=300 and <600)

Note: Make sure you use the correct criteria and that eg 300 is not included in both ranges (No overlapping). First range goes from 0 to 299 second range goes from 300 to 599!
Therefore I used >= and <. Make sure that = is only used in the upper OR the lower of these both criteria.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.