CTRDevelopments
New Member
- Joined
- Nov 16, 2020
- Messages
- 8
- Office Version
- 365
- Platform
- Windows
Hi, I have a master excel document which holds all of the VBA code. I need this to open up a different excel BOM and remove some lines from it. I have the code open up the second excel file but the filering and row deletion code (looking in this case for a row in column c containing "Roof Plan", seem to try to filter the master excel which clearly goes badly wrong. I am not quite sure what I have done wrong here as I have tried to set the BOM file as the active worksheet etc.
If I copy the code into the BOM file it works as intended so I can only assume it is something to do with the vba residing on the master file not the BOM file.
Any help is much appreciated
cheers
If I copy the code into the BOM file it works as intended so I can only assume it is something to do with the vba residing on the master file not the BOM file.
Any help is much appreciated
cheers
VBA Code:
Dim MyFilePath As String
Dim FileName As String
Dim FullFileName As String
MyFilePath = ThisWorkbook.Path
FileName = "\Drawings\Complete_BOM.xlsm"
FullFileName = MyFilePath & FileName
Set WkB = Workbooks.Open(FullFileName)
Workbooks("Complete_BOM.xlsm").Activate
Worksheets("Sheet1").Activate
With ActiveSheet
.AutoFilterMode = False
With Range("c1", Range("c" & Rows.Count).End(xlUp))
.AutoFilter 1, "Roof Plan"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With