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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

dcnick

Board Regular
Joined
May 5, 2003
Messages
62
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.
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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
 

Forum statistics

Threads
1,137,201
Messages
5,680,136
Members
419,885
Latest member
Murugesha

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
Top