Ok been playing with this code for a little while and I will explain what it does. It takes any blank/no value cell in column "E" and copies that row to another sheet called "MISSED INSPECTION ITEMS" It is tied to a virtual button and the command for it is issued when that excel button is pressed. So far it works great but with one minor problem. I need to also have it pick up text keywords. For example. It needs to look for a blank/no value cell in column "E" or the words "NO ACCESS" etc. I have tried adding "IF" statements with "or" like prev code examples but never have any luck. The other thing is that the way the code is written on the "MISSED INSPECTION ITEMS" page it will clear the row the second a letter is entered into the "E" column. I am trying to make it so that whatever status is chosen on the "MISSED INSPECTION ITEMS" page will remove it from that page and update the "INITIATING DEVICES" page column "E'
So far no luck here is what I have so far (this is what is assigned to an excel module and activated via run macro or the button)
Code:
Sub Find_missed_devices()
Dim sh1 As Worksheet, sh2 As Worksheet, rng As Range, lr As Long
Set sh1 = Sheets("INITIATING DEVICES")
Set sh2 = Sheets("MISSED INSPECTION ITEMS")
'Set the range for the inspection results column
lr = sh1.Cells(Rows.Count, 2).End(xlUp).Row
Set rng = sh1.Range("E7:E" & lr)
'Isolate the missing or empty results columns and copy rows to sheet 2 (MISSED INSPECTION ITEMS)
rng.SpecialCells(xlCellTypeBlanks).EntireRow.Copy sh2.Range("A7")
With sh2
If Application.CountIf(.Range("C7", .Cells(Rows.Count, 3).End(xlUp).Offset(0, 1)), "") > 0 Then
.Range("C7", .Cells(Rows.Count, 3).End(xlUp).Offset(0, 1)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End If
End With
End Sub
This is what is actually in the page code of the "MISSED INSPECTION ITEMS" page
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Long, rng As Range
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range("E7:E" & lr)
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, rng) Is Nothing Then
For Each c In Sheets("INITIATING DEVICES").Range("E:E")
If Target.Offset(0, -1).Value = c.Value And Target.Offset(0, -2).Value = c.Offset(0, -1).Value Then
c.Offset(0, 1) = Target.Value
Exit For
End If
Next
Target.EntireRow.Delete
End If
End Sub
I will keep playing with this as I have tons of backups to keep myself busy
Thanks again
Bookmarks