Dynamic sumif function using VBA

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
Raghavendra BBusiness Operations AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Please provide a workbook or a picture that shows the results that you would like to see.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Raghavendra BBusiness Operations AnalystAuthor Commented:
9.19-Capture.PNG
I have uploaded the file and also the screen shot, i need dynamic horizontal sumif function
Test.xlsm
0
Martin LissOlder than dirtCommented:
Click Ctrl+Shift+T in the attached workbook. (I could add a button on Sheet1 if you want)
29118428.xlsm
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Raghavendra BBusiness Operations AnalystAuthor 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
0
Martin LissOlder than dirtCommented:
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.
0
Raghavendra BBusiness Operations AnalystAuthor 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
0
Martin LissOlder than dirtCommented:
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.
0
Raghavendra BBusiness Operations AnalystAuthor 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
0
Martin LissOlder than dirtCommented:
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)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.