Mr_Ragweed
Board Regular
- Joined
- Dec 10, 2012
- Messages
- 74
Hi,
I'm trying very hard to solve my own code issues but hours have turned to days on what should probably only be a few lines of script.
My Code is below:
The part in red is the obvious error (or at least 1 of them).
The goal of this macro is to find the last cell in Column A on 1 worksheet, Find its match somewhere on a second worksheet, Delete the match and shift cells up so there are no blanks left behind.
I really need help. I've read many posts and tried to adapt them but apparently i'm not smart enough. Most posts seem to be related to using a formula instead of VBA.
Thanks!
I'm trying very hard to solve my own code issues but hours have turned to days on what should probably only be a few lines of script.
My Code is below:
Code:
Sub Edit_Dropdown_Lists()
'Hopefully this will be a worksheet event that when data is populated to the ProductFormulas_
'sheet this macro will delete the matching product from the ProdXDept sheet
Dim FinalRow As Long
Dim FinalCol As Long
Dim rngFnd As Range
Dim LRow As Long
FinalRow = ActiveSheet.Cells(Application.Rows.Count, 1).End(xlUp).Row
FinalCol = ActiveSheet.Cells(1, Application.Columns.Count).End(xlToLeft).Column
If Sheets("ProductFormulas").Select = True Then
Cells(FinalRow, 1).Select
With Sheets("PrdXDept")
LRow = Cells(Rows.Count, "A").End(xlUp).Row
Set rngFnd = Sheets("PrdXDept").Range("A2:J2" & FinalRow)
If rngFnd.Value = Sheets("ProductFormulas").Range(FinalRow, 1).Value Then
[COLOR=#FF0000] rngFnd.Select[/COLOR]
Selection.Delete Shift:=xlUp
ElseIf rngFnd.Value <> Sheets("ProductFormulas").Range(FinalRow, 1).Value Then
Exit Sub
End If
End With
End If
End Sub
The goal of this macro is to find the last cell in Column A on 1 worksheet, Find its match somewhere on a second worksheet, Delete the match and shift cells up so there are no blanks left behind.
I really need help. I've read many posts and tried to adapt them but apparently i'm not smart enough. Most posts seem to be related to using a formula instead of VBA.
Thanks!