I have a working spread sheet that adds, removes (for tracking), and erases custom rows in a workbook.
My AddNMP macro is tied to the button on the "Forecast" sheet and is working as intended. The RemoveNMP (assigned to 'Remove Temp' control) and DeleteNMP (assigned to "X" control) macros are working for the most part, but I'm running into issues selecting and deleting the button not pressed.
My goal is to allow the end user to select "Remove Temp" or "X" from primary table on the "Forecast" sheet.
*"X" control selects the row and deletes it entirely, without inserting it anywhere else.
*"Remove Temp" selects the row and inserts a parsed version (sans "Remove Temp" control) to the "Falloff" sheet. While "Remove Temp" parses itself out when being copied to "Falloff", I would like to keep the "X" control intact so that the user can edit the "Falloff" sheet using the same functionality.
In both instances, I'm able to delete the active shape (the control selected), but I'm not able to select and delete the control next to it. I've tried using a For... Each statement to accomplish this, but it's not working. Any recommendations?
'
' DeleteNMP Macro
' Macro selects, cuts, then deletes row range; for editing usage
'
Sub DeleteNMP()
Dim ShpRng As Shape
With ActiveSheet.Shapes(Application.Caller)
.TopLeftCell.Select
'Selects cell directly below shape control activated to begin macro
ControlIndex = Application.Caller
'Stores the control selected for deletion
For Each ShpRng In ActiveSheet.Row
If Not Intersect(ShpRng.TopLeftCell, Range.EntireRow) Is Nothing Then ShpRng.Delete
Next ShpRng
'ActiveSheet.Shapes(ControlIndex).Delete
'Deletes row and control
End With
End Sub
Bookmarks