Hey everyone! Does anyone know how I would search a column for a particular value and duplicate the row in which the value is found in VBA? I also want to amend a cell in the duplicated row if possible. I would like to take the top table and make it look like the bottom table in the included example. I want to duplicate any row with salary and add “- Other” to the employee’s name.
I tried doing something like this:
For i = 11 To lastrow
ws.Select
If UCase(Cells(i, "C")) = "SALARY" And UCase(Cells(i, "A")) <> "" Then
Range(("A" & i) & ":" & ("R" & i)).Select
Range(("A" & i) & ":" & ("R" & i)).Copy
Selection.Insert Shift:=xlDown
However, it created a never-ending loop, and I am unsure how to amend the cell names for a duplicate row. Any help would be appreciated. Thank you!
I tried doing something like this:
For i = 11 To lastrow
ws.Select
If UCase(Cells(i, "C")) = "SALARY" And UCase(Cells(i, "A")) <> "" Then
Range(("A" & i) & ":" & ("R" & i)).Select
Range(("A" & i) & ":" & ("R" & i)).Copy
Selection.Insert Shift:=xlDown
However, it created a never-ending loop, and I am unsure how to amend the cell names for a duplicate row. Any help would be appreciated. Thank you!