On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.
Sub delete_fault() ' this sub deletes a column in the OEE History Page when a fault is deleted from the userform. Only ' executes if there is data already written to the OEE History Sheet Set OEEwkset = Worksheets("OEE History") Set wksdata = Worksheets("DATA STORE") 'compare the new range aagainst current OEE History title range and delete entire columns from OEE HIstory that dont match. If OEEwkset.Cells(1, 2).Value <> "" Then ' if data is recorded then.. Set CLL = OEEwkset.Rows(1).Find _ ("DOWNTIME", OEEwkset.Cells(1, OEEwkset.Columns.Count), xlValues, xlWhole) With OEEwkset Set rng_history = .Range(.Cells(1, 2), .Cells(1, CLL.Column - 1)) End With Set rng = Range("FAULT_RANGE") For Each cel In rng_history.Cells fndval = Application.Match(cel.Value, rng, 0) If IsError(fndval) Then If Not delrng Is Nothing Then If Intersect(delrng, cel.EntireColumn) Is Nothing Then Set delrng = Union(delrng, cel.EntireColumn) End If Else Set delrng = cel.EntireColumn End If End If Next cel OEEwkset.Activate If Not delrng Is Nothing Then delrng.Select'<---------HITS ERROR HERE delrng.EntireColumn.Delete End If End If End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.