VBA to insert column and row headings and formulas

beaglej1

New Member
Joined
May 30, 2019
Messages
4
Hello experts!
I collect information submitted by local constituents using an excel form. I would like automate the tallying of information collected on tabs that may be inserted into the excel form (copies of the tab Part II-SubContracts) using VBA. I will also need to share this macro with co-workers. While I am sure there is an easier way to do this, this is what I would like to try to do. Any assistance is greatly appreciated.

A link to the excel file I'm using: https://www.dropbox.com/s/p966l27nvlo5mlk/ds4513%20test%20subcontract%20line%20totals.xlsx?dl=0
I started a mock up of what I'm looking for this to do.

On the Department Use Only tab, starting in cell L16 and going down (through L57), I want to insert the row headings below. It’s the same information repeated once with two blank rows in between them:
1xx, 293
21x
22x
231
232
233
24x
25x
26x
27x
281
282
283
284
285
289
29x
3xx
4xx
45x
1xx, 293
21x
22x
231
232
233
24x
25x
26x
27x
281
282
283
284
285
289
29x
3xx
4xx
45x

<tbody>
</tbody>

Then, starting in M15 and going across, I want to insert the formula =B40. In N15, =B41. In O15, =B42. This will continue across through column V. (see example) Finally, insert the word Totals inserted into W15.

Starting in M16, I would like to begin inserting formulas. These formulas will continue down through row 57 and across through column V.
Examples:
M16 =IF(ISERROR(INDIRECT("'"&$B$40&"'!AV6")),0,INDIRECT("'"&$B$40&"'!AV6"))
M17 =IF(ISERROR(INDIRECT("'"&$B$40&"'!AV7")),0,INDIRECT("'"&$B$40&"'!AV7"))
M18 =IF(ISERROR(INDIRECT("'"&$B$40&"'!AV8")),0,INDIRECT("'"&$B$40&"'!AV8"))

N16 =IF(ISERROR(INDIRECT("'"&$B$41&"'!AV6")),0,INDIRECT("'"&$B$41&"'!AV6"))
N17 =IF(ISERROR(INDIRECT("'"&$B$41&"'!AV7")),0,INDIRECT("'"&$B$41&"'!AV7"))
N18 =IF(ISERROR(INDIRECT("'"&$B$41&"'!AV8")),0,INDIRECT("'"&$B$41&"'!AV8"))

In cells W16 through W58, I’d like to sum across. For instance:
W16 =SUM(M16:V16)
W17 =SUM(M17:V17)

Finally, I’d like to format W16-W58 as a number (or accounting) with commas and 2 decimal places.

Any help is greatly appreciated. Thank you so much!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,215,556
Messages
6,125,495
Members
449,235
Latest member
Terra0013

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