I have a piece of code that works on my sample data but I need some help to make it work in project spreadsheet.
Code currently calls out Sheets 1, 2 and 3 and put the results in Sheet 4.
I'd like it to call out data from renamed sheets - NIC1, NIC2 and ILO and put the results in sheet named ORDER.
I need to change it because I have more sheets in use and some of them are hidden. Also sheets NIC1, NIC2 and ILO are not first 3 sheets in the workbook.
Sub sort_delete()
Dim cell As Range, cell2 As Range
Dim r As Long, r2 As Long, a As Long
Dim f As Integer, sh As Integer
ActiveWorkbook.Sheets(1).Activate
'In Order Copy/Paste
Range("A1:C" & Range("A65536").End(xlUp).Row).Copy _
Destination:=Sheets(4).Range("A1")
For sh = 2 To 3
Sheets(sh).Activate
For Each cell In Range("A2:A" & Range("A65536").End(xlUp).Row)
r = cell.Row
f = 0
For a = Sheets(4).Range("A65536").End(xlUp).Row To 2 Step -1
If StrComp(cell.Text, Sheets(4).Range("A" & a).Text, vbTextCompare) = 0 Then
Sheets(sh).Select
Rows(r).Select
Application.CutCopyMode = False
Selection.Copy
Sheets(4).Select
Rows(a + 1).Select
Selection.Insert shift:=xlDown
f = 1
Exit For
End If
Next a
If f = 0 Then
cell.EntireRow.Copy Destination:=Sheets(4).Range("A" & Range("A65536").End(xlUp).Offset(1, 0).Row)
End If
Next cell
Next sh
'Hide SP0
Sheets(4).Activate
For Each cell In Range("C2:C" & Range("A65536").End(xlUp).Row)
If InStr(cell.Text, "SP0") Then
cell.EntireRow.Hidden = True
End If
Next cell
End Sub
Any suggestions?
Bookmarks