I'm in need of a VBA Solution. I can't figure out how to have VBA check a named range "UnitPrice" to see if any of the cells in that range contain a comment. If not, then call module InsertRowsSP, if so, then display message box and end sub.
Basically, if the unit price has been lock or had a override applied (which adds a comment to the cell automatically), then no new rows can be added.
Below is the code I am trying, but its not working right.
Sub FindCommentsSp()
Dim Targetcells As Range
Dim MyRange As Range
Set MyRange = Range("SpUnitPrice")
On Error Resume Next
Selection.SpecialCells(xlCellTypeComments).Select
Set Targetcells = Selection
If Application.Intersect(MyCell, Targetcells) Is Nothing _
Then Call InsertRowsSP _
Else MsgBox ("Cannot add rows after price is locked or override is used")
Sheets("Sp Est").Activate
End Sub
Thanks
Mark
Basically, if the unit price has been lock or had a override applied (which adds a comment to the cell automatically), then no new rows can be added.
Below is the code I am trying, but its not working right.
Sub FindCommentsSp()
Dim Targetcells As Range
Dim MyRange As Range
Set MyRange = Range("SpUnitPrice")
On Error Resume Next
Selection.SpecialCells(xlCellTypeComments).Select
Set Targetcells = Selection
If Application.Intersect(MyCell, Targetcells) Is Nothing _
Then Call InsertRowsSP _
Else MsgBox ("Cannot add rows after price is locked or override is used")
Sheets("Sp Est").Activate
End Sub
Thanks
Mark