VBA: Creating table & Filling correct data

PerttiPP

New Member
Joined
Nov 12, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi all and thanks in advance,
I have a list of services and resources what services are using. The list is updating every week and I still want to follow the trends and see how is every service progressing. I have created VBA macro to create new sheet for every time I want to analyze data set and it automatically copies list to the new sheet.

An example below. The list on the left side is my source data which is in the main sheet. I would like to get the data to table form which is on the right side. Then I would have only one row for each service and I would see which of those five resources services are having. Is it possible to create with some lookup function or what kind of VBA code I should create? It should have some kind of "finding" function to fill data to correct place.

Capture.PNG
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
No need for VBA here - you have two different options.

You can add your data to a pivot table and add your data to rows and columns (and apply conditional formatting) to get the following table.

1637072367843.png



Or, since you are using M365, you can use the amazing new dynamic array formulas. To make your table, three formulas do the trick. One to generate a unique list of row headers, one for the column headers, and one for the values.
MrExcel.xlsm
PQRSTU
212345
3A11111
4B10100
5C10011
Sheet1
Cell Formulas
RangeFormula
Q2:U2Q2=TRANSPOSE(UNIQUE(Table3[resource]))
P3:P5P3=UNIQUE(Table3[service])
Q3:U5Q3=COUNTIFS(Table3[service],P3#,Table3[resource],Q2#)
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
Q3:U5Other TypeIcon setNO



However, it also would be possible to procedurally create the table in VBA too, if it's something you definitiely require.
 
Upvote 0
Solution
No need for VBA here - you have two different options.

You can add your data to a pivot table and add your data to rows and columns (and apply conditional formatting) to get the following table.

View attachment 51359


Or, since you are using M365, you can use the amazing new dynamic array formulas. To make your table, three formulas do the trick. One to generate a unique list of row headers, one for the column headers, and one for the values.
MrExcel.xlsm
PQRSTU
212345
3A11111
4B10100
5C10011
Sheet1
Cell Formulas
RangeFormula
Q2:U2Q2=TRANSPOSE(UNIQUE(Table3[resource]))
P3:P5P3=UNIQUE(Table3[service])
Q3:U5Q3=COUNTIFS(Table3[service],P3#,Table3[resource],Q2#)
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
Q3:U5Other TypeIcon setNO



However, it also would be possible to procedurally create the table in VBA too, if it's something you definitiely require.
Thanks for answer. Hope this will help. I actually have to create VBA code for this because the source data is quite big and I anyway need to automate this process.
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,855
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top