Todes Angst
New Member
- Joined
- Sep 1, 2014
- Messages
- 4
Hi All,
I've got a situation in a spreadsheet i'm working with where I have to identify all the occurrences of a certain value in a specified column and export the rows. I have been using this macro script to good effect when I need to extract a single row:
Now in the spreadsheet (see below) I want to find all instances of the cells in C$:C$ that contain the text "Duplicate Of XXXXXXXX" and export them to another worksheet (Exactly like the script above would do). However, the cells containing the "Duplicates" are generated using "=CONCATENATE("DUPLICATEOF",<another cell="">)" type functions and are all unique. SO I've used conditional formatting to change their color to green and then used a standard color filter to filter them. HOWEVER, I also need to export the row directly above each "Duplicate" row at the same time (i.e the "original" and the "duplicate" rows together).
Can someone suggest a way to do this?
</another>
I've got a situation in a spreadsheet i'm working with where I have to identify all the occurrences of a certain value in a specified column and export the rows. I have been using this macro script to good effect when I need to extract a single row:
Sub cpyX()
Dim lr As Long, rng As Range, sh As Worksheet
Dim nWB As Workbook, sh2 As Worksheet, lr2 As Long
Set sh = ThisWorkbook.ActiveSheet
lr = sh.Cells(Rows.Count, 4).End(xlUp).Row
Set rng = Range("C2:C" & lr)
Set nWB = Workbooks.Add
ActiveWorkbook.SaveAs Filename:="<--output dir and filename---->"
Set sh2 = nWB.Sheets(1)
For Each c In rng
If UCase(c) = "<---search text --->" Then
lr2 = sh2.Cells(Rows.Count, 1).End(xlUp).Row
c.EntireRow.Copy sh2.Range("A" & lr2 + 1)
End If
Next
End Sub
Now in the spreadsheet (see below) I want to find all instances of the cells in C$:C$ that contain the text "Duplicate Of XXXXXXXX" and export them to another worksheet (Exactly like the script above would do). However, the cells containing the "Duplicates" are generated using "=CONCATENATE("DUPLICATEOF",<another cell="">)" type functions and are all unique. SO I've used conditional formatting to change their color to green and then used a standard color filter to filter them. HOWEVER, I also need to export the row directly above each "Duplicate" row at the same time (i.e the "original" and the "duplicate" rows together).
Can someone suggest a way to do this?