Auto Insert

skipwith

New Member
Joined
Sep 19, 2006
Messages
6
Hi,

I have a spreadsheet with multiple records Eg.

01/09/2006 JOB2 3,500
01/09/2006 JOB2 10000
01/09/2006 JOB2 100
01/09/2006 JOB3 10
01/09/2006 JOB3 100

Could you tell me how I use VBA to insert a line when the Job number changes and then total up the end column by Job?

Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi skipwith. Try this:

Code:
Sub GetSum()

Dim counter As Integer

Sheets("Sheet1").Range("B1").Select
Do Until ActiveCell.Value = ""

  counter = 1
  Do Until ActiveCell.Value <> ActiveCell.Offset(1, 0).Value
    Selection.Offset(1, 0).Select
    counter = counter + 1
  Loop

  Selection.Offset(1, 0).Select
  ActiveCell.EntireRow.Select
  Selection.Insert Shift:=xlDown
  ActiveCell.Offset(0, 2).Select
  ActiveCell.Formula = "=SUM(R[-" & counter & "]C:R[-1]C)"
  Selection.Offset(1, -1).Select

Loop

End Sub

Hope this helps.
 
Upvote 0
Welcome to the Board!

How about Data-->Subtotals-->At each change in-->Job Number-->Sum-->Revenue column.

I'll take a native solution any day. ;)

HTH,

Smitty
 
Upvote 0

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

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