VBA Help - Find Text Value, Insert Rows, Multiply Values based on %

roseinsydney

New Member
Joined
May 25, 2022
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Hoping for an Excel VBA genius to help me with a macro project (fingers crossed)!!

1653530272220.png


Dataset: column C contains cost centres. If the cost centre strings = WH or TSG, break down into further cost centres based on percentage.

Taking "WH" as example, usually Ctrl+F to find "WH", then insert 13 lines, manually copy the new cost centres into column C, and multiply the amount by % using a ROUND formula for 2 decimal places.

To avoid any $0.01 rounding issues for the last multiplication (in this case QSDW) subtract the calculations so far from original amount.

Ctrl+D to copy down the value in Column A and B without changing it

Then ensure "WH" is deleted from the list once it has been updated with the broken down cost centres.

Repeat!

1653530307898.png


Complexities:
  • WH (or TSG, etc) can be located at any row in Column C, for an undefined amount of times (say maximum 10) so code would need to loop, then move on once all replaced
  • WH will always require 13 sub-levels, other codes (eg. TSG) require 8.


Book1
ABCDEFGHIJ
150400APCITG73,977.00WH%TSG%
250400ASBRNI52,480.00ACDW0.007BVDC0.024
350400ASCDGM64,595.00BVDW0.031CIDC0.057
450400AUBRNA41,984.00CIDW0.044CSDC0.236
550400AUBRNE16,177.00CSDW0.06DIHC0.506
650400AUBRNF19,572.00DIHW0.233GXDC0.049
750400AUBRNH21,896.00FSDW0.011PFDC0.032
850400AUBRNI23,660.00GXDW0.093PSDC0.03
950400AUBRNO35,459.00PFDW0.012QLBC0.066
1050400AUBRNQ65,892.00PFEW0.006
1150400AUBRNR23,207.00PSDW0.094
1250400AUCDGD33,223.00PSPW0.012
1350400AUCDGM47,245.00QLBW0.1
1450400AUCDGP11,852.00QSDW0.297
1550400AUCDGT34,609.00
1650400AULSGD30,120.00
1750400AULSGM2,057.00
1850400AULSGP78,303.00
1950400AULSGT50,900.00
2050400CRPBRNZ52,739.00
2150400AUWH40,265.00
2250415AUBRNO72,934.00
2350415AUWH30,344.00
2450420AUBRNF2,195.00
2550420AUCDGM21,241.00
2650420AUTSG59,620.00
2750440AUWH77,334.00
2850444ASCDGM2,151.00
2950444AUBRNE33,290.00
3050444AUBRNF44,023.00
3150444AUBRNH14,261.00
3250444AUBRNQ32,593.00
3350444AUBRNR47,410.00
3450444AUCDGD65,344.00
3550444AUCDGM24,516.00
3650444AUCDGP52,749.00
3750444AULSGD30,818.00
3850444AULSGM28,777.00
3950444AULSGP35,531.00
4050444AUTSG33,328.00
4150444AUWH28,998.00
4250448AUTSG28,981.00
4350600APCITG49,471.00
4450600ASBRNI16,860.00
4550600ASCDGM39,369.00
4650600AUBRNA69,235.00
4750600AUBRNE50,355.00
4850600AUBRNF57,247.00
4950600AUBRNH19,228.00
5050600AUBRNI23,121.00
5150600AUBRNO22,752.00
5250600AUBRNQ79,603.00
5350600AUBRNR16,169.00
5450600AUCDGD54,267.00
5550600AUCDGM65,565.00
5650600AUCDGP25,930.00
5750600AUCDGT8,641.00
5850600AULSGD51,692.00
5950600AULSGM5,671.00
6050600AULSGP37,474.00
6150600AULSGT14,607.00
6250600CRPBRNZ70,420.00
6350600AUTSG55,966.00
6450600AUWH35,974.00
65
66Example: Row above broken down
6750600AUACDW251.82
6850600AUBVDW1,115.19
6950600AUCIDW1,582.86
7050600AUCSDW2,158.44
7150600AUDIHW8,381.94
7250600AUFSDW395.71
7350600AUGXDW3,345.58
7450600AUPFDW431.69
7550600AUPFEW215.84
7650600AUPSDW3,381.56
7750600AUPSPW431.69
7850600AUQLBW3,597.40
7950600AUQSDW10,684.28
Macro
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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