I have two tables, one that feeds the other based on user entries.
This the only interaction, add data to one and it feeds data to the other.
The problem is, if I delete information from the feeder table, the records are still kept in the storage table.
This is a problem as projects are routinely cancelled and I do not want them clogging up the storage table as if they are useful information.
I currently have the code on my storage table that can delete any rows I want it to delete:
My problem is, it doesn't do anything as I haven't tied it to the deletion event.
I want my feeder worksheet to prompt the user when they try to delete a row. Once they confirm they are really trying to delete the row, the macro above runs on the storage worksheet.
Here is what I have so far:
Any help is appreciated. There are many different lines of code out there that don't really do what I want.
I figure I need to use a bunch of If statements.
This the only interaction, add data to one and it feeds data to the other.
The problem is, if I delete information from the feeder table, the records are still kept in the storage table.
This is a problem as projects are routinely cancelled and I do not want them clogging up the storage table as if they are useful information.
I currently have the code on my storage table that can delete any rows I want it to delete:
Code:
Sub TestDeleteRows()
Dim rFind As Range
Dim rDelete As Range
Dim strSearch As String
[B][COLOR=#ff0000]strSearch = "YYY" 'I need to tie this to my code below[/COLOR][/B]
Set rDelete = Nothing
Application.ScreenUpdating = False
With Sheet2.Columns("C:C")
Set rFind = .Find(strSearch, LookIn:=xlValues, LookAt:=xlPart, SearchDirection:=xlPrevious, MatchCase:=False)
If Not rFind Is Nothing Then
Do
Set rDelete = rFind
Set rFind = .FindPrevious(rFind)
If rFind.Address = rDelete.Address Then Set rFind = Nothing
rDelete.EntireRow.Delete
Loop While Not rFind Is Nothing
End If
End With
Application.ScreenUpdating = True
End Sub
My problem is, it doesn't do anything as I haven't tied it to the deletion event.
I want my feeder worksheet to prompt the user when they try to delete a row. Once they confirm they are really trying to delete the row, the macro above runs on the storage worksheet.
Here is what I have so far:
Code:
Sub DeleteRow()
Dim OnDelete As Integer
Dim Dprompt As String
OnDelete = MsgBox("Are you sure?", vbOKCancel)
Dprompt = "Delete Project?"
With Sheet1
If Selection.EntireRow.Delete Then
MsgBox "Are you Sure?" & OnDelete
If OnDelete = 0 Then
End If
Else
[B][COLOR=#ff0000] ProjectName = YYY 'I am stuck here[/COLOR][/B]
End If
End With
End Sub
If OnDelete = 0 Then
Exit Sub
Else
Any help is appreciated. There are many different lines of code out there that don't really do what I want.
I figure I need to use a bunch of If statements.