Goondock89
New Member
- Joined
- Apr 8, 2020
- Messages
- 1
- Office Version
- 2013
- Platform
- Windows
Good Afternoon,
I've written some VBA code to insert a Vlookup, calculate, filter to a value, and delete the rows that have said value. See below.
This code comes at the beginning of a longer set. Before I execute any code I set calculations to manual.
When I step into the macro and run this it works fine. However when I run the macro the vlookup doesn't refresh and the rows i intended to delete are not deleted.
Hoping someone can help sort this out.
Thank you,
Sub Macro1()
'
' Macro1 Macro
'
'Remove Omitted Job Codes
Sheets("Raw Data").Range("CP1").Value = "Look Up"
Sheets("Raw Data").Range("CP2").Formula = "=IF(ISNA(VLOOKUP($B2,'Look Up'!$A:$B,2,0)),""No"",""Yes"")"
Sheets("Raw Data").Range("CP2").Copy
Sheets("Raw Data").Range("CO2").End(xlDown).Offset(0, 1).Activate
ActiveCell.Name = "Look_Up_End"
Sheets("Raw Data").Range("CP2", "Look_Up_End").PasteSpecial xlFormulas
Sheets("Raw Data").Calculate
On Error Resume Next
Sheets("Raw Data").Range("A1", "CP1").AutoFilter Field:=94, Criteria1:="Yes"
Sheets("Raw Data").Range("A2", "Look_Up_End").SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
Sheets("Raw Data").Columns(94).EntireColumn.Delete
'
End Sub
I've written some VBA code to insert a Vlookup, calculate, filter to a value, and delete the rows that have said value. See below.
This code comes at the beginning of a longer set. Before I execute any code I set calculations to manual.
When I step into the macro and run this it works fine. However when I run the macro the vlookup doesn't refresh and the rows i intended to delete are not deleted.
Hoping someone can help sort this out.
Thank you,
Sub Macro1()
'
' Macro1 Macro
'
'Remove Omitted Job Codes
Sheets("Raw Data").Range("CP1").Value = "Look Up"
Sheets("Raw Data").Range("CP2").Formula = "=IF(ISNA(VLOOKUP($B2,'Look Up'!$A:$B,2,0)),""No"",""Yes"")"
Sheets("Raw Data").Range("CP2").Copy
Sheets("Raw Data").Range("CO2").End(xlDown).Offset(0, 1).Activate
ActiveCell.Name = "Look_Up_End"
Sheets("Raw Data").Range("CP2", "Look_Up_End").PasteSpecial xlFormulas
Sheets("Raw Data").Calculate
On Error Resume Next
Sheets("Raw Data").Range("A1", "CP1").AutoFilter Field:=94, Criteria1:="Yes"
Sheets("Raw Data").Range("A2", "Look_Up_End").SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
Sheets("Raw Data").Columns(94).EntireColumn.Delete
'
End Sub