[VBA QUESTION] Add 2 lines into a table at a certain location and fill in other fields

bnbcat

New Member
Joined
Apr 27, 2016
Messages
41
Office Version
  1. 365
Platform
  1. Windows
I have data like so, in which I need to use VBA to add 2 lines that will always be added after the 5-digit customer number. Additionally, I need to fill in certain fields for those 2 new items, based on the data of the already existing customer accounts.

Original:

CustomerBalanceInterest RateStatusState
35001$300.001.00%10CA
10001$500.001.25%7CA
10356$300.001.50%7CA
10686$800.001.75%7NY
12369$100.001.15%10CA
3068900$(200.00)1.35%6NY
3697431$(100.00)1.75%7NY
3897921$(300.00)1.00%10CA
3196780$(100.00)1.25%7CA
3976451$(200.00)1.15%10NY

<tbody>
</tbody>

What results should show:
<body id="************" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
CustomerBalanceInterest RateStatusState
35001$300.001.00%10CA
10001$500.001.25%10CA
13356$300.001.50%7CA
15686$800.001.75%7NY
12369$100.001.15%10CA
3068900$(200.00)1.35%6NY
3697431$(100.00)1.75%7NY
3897921$(300.00)1.00%10CA
3196780$(100.00)1.25%7CA
3976451$(200.00)1.15%10NY


<tbody>
</tbody>
</body>
CustomerBalanceInterest RateStatusState
35001$300.001.00%10CA
10001$500.001.25%7CA
10356$300.001.50%7CA
10686$800.001.75%7NY
12369$100.001.15%10CA
State$1000.001.55%7
National$4000.001.15%10
3068900$(200.00)1.35%6NY
3697431$(100.00)1.75%7NY
3897921$(300.00)1.00%10CA
3196780$(100.00)1.25%7CA
3976451$(200.00)1.15%10NY

<tbody>
</tbody>


The "State" and "National" rows are the new rows that need to be added. The balances will be manually entered. However, the interest rate for "State" should be the weighted average of the interest rates of accounts starting with "10" and the interest rate for "National" should be the interest rate of the account starting with "12." The Status should have the same status as accounts starting with "10" and the Status for "National" should have the same status as accounts starting with "12." State will remain blank.

Any help will be greatly appreciated.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,215,268
Messages
6,123,966
Members
449,137
Latest member
yeti1016

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