Insert Blank row and sum the values

HECGroups

Board Regular
Joined
Jan 16, 2012
Messages
164
Hello Again,

I am looking for a macros where it insert the blank row above and below if the cell value is repeating within a column G (Batch No.).

Why I need a macros because the data is large about 10 to 20 thousand rows.




Book1
EFGHIJKLMNO
1Provider NameBatch StatusBatch No.Total ClaimsRef No.Batch TypeProcessing DateClaimed AmountNet AmountRejected AmountApproved Amount
2Al Dar Hospital (Quba)SettledNB20150322-1614213/2015-311Network22-03-2015300.0095.00200.00100.00
3Al Dar Hospital (Quba)SettledNB20150316-1431253/2015-224-opsNetwork16-03-2015300.0095.00200.00100.00
4Al Dar Hospital (Quba)SettledNB20150414-2083324/2015-331Network14-04-2015300.0095.00200.00100.00
5Al Dar Hospital (Quba)SettledNB20150524-2865145/2015-416Network24-05-2015300.0095.00200.00100.00
6Al Dar Hospital (Quba)SettledNB20150616-3263396/2015-471Network16-06-2015300.0095.00200.00100.00
7
8Al Dar Hospital (Quba)SettledNB20150803-3996518/2015-583Network03-08-2015300.0095.00200.00100.00
9Al Dar Hospital (Quba)Resubmission AdjustmentNB20150803-399625.00
10-75.00
11Al Dar Hospital (Quba)SettledNB20150824-4424728/2015-665Network24-08-2015300.0095.00100.00100.00
12Al Dar Hospital (Quba)Resubmission AdjustmentNB20150824-4424100.00
13100.00
14Al Dar Hospital (Quba)SettledNB20150929-4945679/2015-736Network29-09-2015300.0095.00200.00100.00
15Al Dar Hospital (Quba)Resubmission AdjustmentNB20150929-494525.00
16-75.00
17Al Dar Hospital (Quba)SettledNB20151020-53787010/2015-783Network20-10-2015300.0095.00200.00100.00
18Al Dar Hospital (Quba)Partially ApprovedNB20151201-61137212/2015-900Network01-12-2015300.0095.00200.00100.00
19Al Dar Hospital (Quba)OpenNB20151229-6683012/2015-OPSNetwork29-12-2015300.0095.00200.00100.00
Statement (2)
Cell Formulas
RangeFormula
O10=SUM(O8:O9)-N8
O13=SUM(O11:O12)-N11
O16=SUM(O14:O15)-N14
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Code:
Sub sumAdj()
Dim i As Long
With ActiveSheet
    For i = .Cells(Rows.Count, "G").End(xlUp).Row To 3 Step -1
        If .Cells(i, 7).Value = .Cells(i - 1, 7).Value Then
            .Rows(i + 1).Insert
            .Cells(i + 1, 15) = (.Cells(i, 15).Value + .Cells(i - 1, 15).Value) - .Cells(i - 1, 14).Value
            .Rows(i - 1).Insert
        End If
    Next
End With
End Sub
 
Upvote 0
Code:
Sub InsertRowsNFormulas()
 Dim LR As Long, k As Long
  LR = Cells(Rows.Count, 7).End(xlUp).Row
  For k = LR To 2 Step -1
   If Cells(k, 7) = Cells(k - 1, 7) Then
    If Cells(k + 1, 7) <> "" Then Rows(k + 1).Insert
     Rows(k - 1).Insert
    Cells(k + 2, 15) = "=SUM(R[-2]C:R[-1]C)-r[-2]c[-1]"
    k = k - 1
   End If
  Next k
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,596
Messages
6,125,732
Members
449,255
Latest member
whatdoido

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