Add rows with specific content after duplicates Excel

Tita_86

New Member
Joined
Apr 20, 2022
Messages
1
Hi All,
I'm trying to find the best way to add an additional row that tells me when the "Exclusion status" column is rejected. Unfortunately, I don't have this data and I need to add this in, but I'm totally failing at this.

All I want to do is to add a row below each "Indicator" (column B) that will copy the last row with data. Then I want to change the ''numerator'' to be the number that will complete the 'denominator' value and change the 'Exclusion Status' to 'Rejected'.
For example, indicator PI01 has numerator=63 out of denominator=149 for 'Accepted' Exclusion Status. I need to add then an additional row below with the remaining numerator=86 to complete the 149. This will be 'Rejected' Exclusion Status for this Indicator.
I added an example below of what I'm trying to do. The yellow rows are what I need in this case.

I hope you can give me some advice, since I really don't know how to do this. I'm quite new with data.. Thanks so much!

1650495234508.png
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Welcome to the Board!

It would be most helpful to us to have a copy of your data that we can work with to create this for you. You have posted an image that we cannot do anything with.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Welcome to the MrExcel board!

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Since we cannot tell from a picture which, if any cells have formulas and we cannot copy the data for testing I have made some guesses.

Here is my sample data. Note that I have assumed the Percentage column contains formulas.

Tita_86.xlsm
ABCDEFGHIJKLMNOPQR
1Hdr1Hdr2Hdr3Hdr4Hdr5Hdr6Hdr7Hdr8Hdr9Hdr10Hdr11Hdr12Hdr13NumeratorDenominatorPercentageHdr17Hdr18
2Dec-21P101x6314942%AcceptedDraft
3Dec-21P102xH1632%AcceptedDraft
4Dec-21P102xL96314%AcceptedDraft
5Dec-21P102xN536384%AcceptedDraft
6Dec-21P1030-4FIPx21644049%AcceptedDraft
7Dec-21P1030-4FTHx14400%AcceptedDraft
Sheet1
Cell Formulas
RangeFormula
P2:P7P2=N2/O2


I run this vba code

VBA Code:
Sub Rejected()
  Dim r As Long, RejRw As Long, Num As Long
  
  Application.ScreenUpdating = False
  For r = Range("B" & Rows.Count).End(xlUp).Row + 1 To 3 Step -1
    Num = Num + Range("N" & r).Value
    If Range("B" & r).Value <> Range("B" & r - 1).Value Then
      Rows(r).Insert
      
      Rows(r - 1).Copy Destination:=Rows(r)
      If Num <> 0 Then
        With Rows(RejRw + 1)
          .Cells(12).ClearContents
          .Cells(14).Value = .Cells(15).Value - Num
          .Cells(17).Value = "Rejected"
        End With
        Num = 0
      End If
      RejRw = r
    End If
  Next r
  Application.ScreenUpdating = True
End Sub

This is what I ended up with

Tita_86.xlsm
ABCDEFGHIJKLMNOPQR
1Hdr1Hdr2Hdr3Hdr4Hdr5Hdr6Hdr7Hdr8Hdr9Hdr10Hdr11Hdr12Hdr13NumeratorDenominatorPercentageHdr17Hdr18
2Dec-21P101x6314942%AcceptedDraft
3Dec-21P101x8614958%RejectedDraft
4Dec-21P102xH1632%AcceptedDraft
5Dec-21P102xL96314%AcceptedDraft
6Dec-21P102xN536384%AcceptedDraft
7Dec-21P102x0630%RejectedDraft
8Dec-21P1030-4FIPx21644049%AcceptedDraft
9Dec-21P1030-4FTHx14400%AcceptedDraft
10Dec-21P1030-4FTHx22344051%RejectedDraft
Sheet1
Cell Formulas
RangeFormula
P2:P10P2=N2/O2


Are we headed in the right direction with any of that?
 
Upvote 0

Forum statistics

Threads
1,223,992
Messages
6,175,826
Members
452,673
Latest member
LaMiaAvy

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