Dynamic sumif function using VBA

Raghavendra B
Raghavendra B used Ask the Experts™
on
VBA code for Dynamic Sumif formula, I have table where each department has plan and actual, number of departments will keep changing, i need to do sumif function for plan and actual seperately irrespective of how many department, also attached file for your reference.

Thanks,
Raghu
Test.xlsm
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Older than dirt
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Please provide a workbook or a picture that shows the results that you would like to see.
Raghavendra BBusiness Operations Analyst

Author

Commented:
9.19-Capture.PNG
I have uploaded the file and also the screen shot, i need dynamic horizontal sumif function
Test.xlsm
Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Click Ctrl+Shift+T in the attached workbook. (I could add a button on Sheet1 if you want)
29118428.xlsm
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Raghavendra BBusiness Operations Analyst

Author

Commented:
Hi Martin,

Thanks a lot for the codes, it really helped me. But can i get sumif formula instead of values in the cell ,so that if the user make any changes in the previous columns then automatically sumif column will be updated.

Thanks,
Raghu
Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
if the user make any changes in the previous columns
In the workbook you posted if I change for example cell B3 the formula works fine, so please describe what kind of change would cause it to not work properly.
Raghavendra BBusiness Operations Analyst

Author

Commented:
Hi,
Apologies if am wrong, My question was ?? -
The output which gets pasted in the cell after running macro is in values and not in a SUMIF - Function,
Example - In the workbook - After running sumif macro cell "N3" value is "3120", instead in need "=Sumif(dynamic reference range,"reference cell,"dynaimc sum range") - like -
I need in cell "N3" to be -  "=SUMIF($B$2:$M$2,$N$2,B3:L3)" - where ranges should be dynamic based on the table size.

Hope this would be more clear about my request -

Thanks,
Raghu
Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
I'm sorry but that isn't what I'm asking.

In your test.xlsm workbook that has the formulas in columns 'N' and 'O', if I change for example cell B3 the formula works fine, so please describe what kind of change would cause it to not work properly.
Raghavendra BBusiness Operations Analyst

Author

Commented:
Hi Martin,

Thanks for the codes, It resolved my requirements. I modified the code a bit according to actual table which i was working.

@ Experts Exchange - This website really helped me many times whenever i get stuck, now am more confident in taking up automation projects, Not only just asking questions, also its easy to find already solved questions which are matching my requirements.

You "EXPERTS" are just great!!!!!

Thanks,
Raghu
Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
              Experts Exchange Top Expert VBA (current)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial