Find 'Missing Coverage' in Column, Then insert a comment in the same row but different column.

bmkelly

Board Regular
Joined
Mar 26, 2020
Messages
172
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am wanting to have the code look to find "Missing Coverage" in a Column that has a header of "Coverage", then when found I need to insert a comment in the same row but different column labeled "Analyst Notes".... Is there a way I can have this go through in a loop for each cell in the column "Coverage" to find "Missing Coverage" to then add a comment in a few columns over in the "Analyst Notes" cell?

Thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
A few questions.
What column is Coverage in?
What column is Analyst Notes in?
What is the comment you want to use?
 
Upvote 0
A few questions.
What column is Coverage in?
What column is Analyst Notes in?
What is the comment you want to use?
Coverage is in Column N
Analyst Notes is in Column V
Comment I would like is "Review - Missing Coverage"

If possible, I would like the code to search in the headers for "Coverage" then go down the columns cells to search for Missing Coverage etc. That way if any other analyst decides to add any columns it could potentially mess up the code.

Thanks!
 
Upvote 0
Ok, how about
VBA Code:
Sub bmkelly()
   Dim Ccol As Range, ANcol As Range
  
   Set Ccol = Range("1:1").Find("Coverage", , , xlWhole, , , False, , False)
   If Ccol Is Nothing Then
      MsgBox "Coverage column not found"
      Exit Sub
   End If
   Set ANcol = Range("1:1").Find("Analyst Notes", , , xlWhole, , , False, , False)
   If ANcol Is Nothing Then
      MsgBox "Analyst Notes column not found"
      Exit Sub
   End If
  
   With Ccol.EntireColumn
      .Replace "Missing Coverage", "=true", xlWhole, , False, , False, False
      On Error Resume Next
      .SpecialCells(xlFormulas, xlLogical).Offset(, ANcol.Column - .Column).Value = "Review - Missing Coverage"
      On Error GoTo 0
   End With
End Sub
This assumes you do not have a formula in the Coverage column that could return True
 
Upvote 0
Ok, how about
VBA Code:
Sub bmkelly()
   Dim Ccol As Range, ANcol As Range
 
   Set Ccol = Range("1:1").Find("Coverage", , , xlWhole, , , False, , False)
   If Ccol Is Nothing Then
      MsgBox "Coverage column not found"
      Exit Sub
   End If
   Set ANcol = Range("1:1").Find("Analyst Notes", , , xlWhole, , , False, , False)
   If ANcol Is Nothing Then
      MsgBox "Analyst Notes column not found"
      Exit Sub
   End If
 
   With Ccol.EntireColumn
      .Replace "Missing Coverage", "=true", xlWhole, , False, , False, False
      On Error Resume Next
      .SpecialCells(xlFormulas, xlLogical).Offset(, ANcol.Column - .Column).Value = "Review - Missing Coverage"
      On Error GoTo 0
   End With
End Sub
This assumes you do not have a formula in the Coverage column that could return True
That's perfect! One thing....and I tried to remove it but then it messes up the code is instead of replacing Missing Coverage with TRUE can it just stay as Missing Coverage?
 
Upvote 0
Oops, missed line it should be
VBA Code:
Sub bmkelly()
   Dim Ccol As Range, ANcol As Range
  
   Set Ccol = Range("1:1").Find("Coverage", , , xlWhole, , , False, , False)
   If Ccol Is Nothing Then
      MsgBox "Coverage column not found"
      Exit Sub
   End If
   Set ANcol = Range("1:1").Find("Analyst Notes", , , xlWhole, , , False, , False)
   If ANcol Is Nothing Then
      MsgBox "Analyst Notes column not found"
      Exit Sub
   End If
  
   With Ccol.EntireColumn
      .Replace "Missing Coverage", "=true", xlWhole, , False, , False, False
      On Error Resume Next
      .SpecialCells(xlFormulas, xlLogical).Offset(, ANcol.Column - .Column).Value = "Review - Missing Coverage"
      On Error GoTo 0
      .Replace "=true", "Missing Coverage", xlWhole, , False, , False, False
   End With
End Sub
 
Upvote 0
Solution
T
Oops, missed line it should be
VBA Code:
Sub bmkelly()
   Dim Ccol As Range, ANcol As Range
 
   Set Ccol = Range("1:1").Find("Coverage", , , xlWhole, , , False, , False)
   If Ccol Is Nothing Then
      MsgBox "Coverage column not found"
      Exit Sub
   End If
   Set ANcol = Range("1:1").Find("Analyst Notes", , , xlWhole, , , False, , False)
   If ANcol Is Nothing Then
      MsgBox "Analyst Notes column not found"
      Exit Sub
   End If
 
   With Ccol.EntireColumn
      .Replace "Missing Coverage", "=true", xlWhole, , False, , False, False
      On Error Resume Next
      .SpecialCells(xlFormulas, xlLogical).Offset(, ANcol.Column - .Column).Value = "Review - Missing Coverage"
      On Error GoTo 0
      .Replace "=true", "Missing Coverage", xlWhole, , False, , False, False
   End With
End Sub
This is perfect! Thank you. I might be in touch down the road as I will most likely try to utilize this code to help me essentially do the same thing but with different columns etc. but same logic!
 
Upvote 0
Glad to help & thanks for the feedback.
Youre welcome! So I essentially took the same code but I am wanting it to look in the Transaction Type Column and if the cell says Addition I need it to look at the WarrantyEnd Column and if the cell is Blank I need it to make a note in the Analyst Notes Column and say "Review - Missing Warranty - Addition" I follow most of the code but the .SpecialCells part so I assume I need to have something in my code to searh for a blank cell in WarrantyEnd column...

VBA Code:
Sub BlankWarranty()

'Looks for Additions with a Blank Warranty in WarrantyEnd Column'

   Dim TTol As Range
   Dim WECol As Range
   Dim ANCol As Range
 
    Set TTCol = Range("1:1").Find("Transaction Type", , , xlWhole, , , False, , False)
        If TTCol Is Nothing Then
            MsgBox "Transaction Type Column Not Found"
        Exit Sub
   
    End If
 
    Set WECol = Range("1:1").Find("WarrantyEnd", , , xlWhole, , , False, , False)
        If WECol Is Nothing Then
            MsgBox "WarrantyEnd Column Not Found"
        Exit Sub
     
    End If
 
    Set ANCol = Range("1:1").Find("Analyst Notes", , , xlWhole, , , False, , False)
        If ANCol Is Nothing Then
            MsgBox "Analyst Notes Column Not Found"
        Exit Sub
     
    End If
 
    With TTCol.EntireColumn
        On Error Resume Next
            .SpecialCells(xlFormulas, xlLogical).Offset(, ANCol.Column - .Column).Value = "Review - Blank Warranty - Addition"
        On Error GoTo 0
     
    End With
 
    With TTCol.EntireColumn
        .Replace "Addition", "=true", xlWhole, , False, , False, False
            On Error Resume Next
        .SpecialCells(xlFormulas, xlLogical).Offset(, ANCol.Column - .Column).Value = "Review - Blank Warranty - Addition"
            On Error GoTo 0
        .Replace "=true", "Addition", xlWhole, , False, , False, False
     
    End With
 
End Sub
 
Last edited:
Upvote 0
That is a significantly different question & will need a different approach. So I suggest that you start a new thread for this question.
 
Upvote 0

Forum statistics

Threads
1,215,410
Messages
6,124,756
Members
449,187
Latest member
hermansoa

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