dipkchopra
New Member
- Joined
- Nov 19, 2013
- Messages
- 13
Hi all,
I am trying to create a user defined function using VBA.
The goal is to create a formula based pivot out of two columns - one containing names and the other containing amounts.
The formula should throw out unique list of names in first column and sum of those names in second column
I tried creating Function Sumpivot(getnames As Range, getamounts As Range)
Code to get first column of my answer = Application.Unique(getnames)
and code for second column = Application.SumIfs(getamounts, getnames, Application.Unique(getnames))
I tried - sumpivot = Application.Unique(getnames) & Application.SumIfs(getamounts, getnames, Application.Unique(getnames)) - this does not work
My problem is how do I load both of these in one output?
This is what I am trying to achieve:
Please guide
and thanks in advance.
I am trying to create a user defined function using VBA.
The goal is to create a formula based pivot out of two columns - one containing names and the other containing amounts.
The formula should throw out unique list of names in first column and sum of those names in second column
I tried creating Function Sumpivot(getnames As Range, getamounts As Range)
Code to get first column of my answer = Application.Unique(getnames)
and code for second column = Application.SumIfs(getamounts, getnames, Application.Unique(getnames))
I tried - sumpivot = Application.Unique(getnames) & Application.SumIfs(getamounts, getnames, Application.Unique(getnames)) - this does not work
My problem is how do I load both of these in one output?
This is what I am trying to achieve:
DATA: | |
C | 1 |
B | 2 |
B | 3 |
A | 4 |
A | 1 |
A | 2 |
Output | |
C | 1 |
B | 5 |
A | 7 |
Please guide
and thanks in advance.