Thanks for the reply
See my first macro which combines several macros
Sub Update()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Clear_Data
Open_Workbook
Trim Data
Remove_Leading_Spaces_CommSheets
Delete_Rows_UnwantedText
AdjustRowHeight
TrimData
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Sub Clear_Data()
With Sheets("Data Import")
.UsedRange.ClearContents
End With
End Sub
Sub Open_Workbook()
ChDir "C:\downloads"
A:
Dim A As Variant
Dim LR As Long
A = Application.GetOpenFilename(MultiSelect:=True)
If TypeName(A) = "Boolean" Then Exit Sub
Dim File As Variant
Application.ScreenUpdating = False
For Each File In A
With Workbooks.Open(File)
With Sheets(1)
.Range("a1", .Range("Y" & Rows.Count).End(xlUp)).Copy _
Destination:=ThisWorkbook.Sheets("Data Import").Range("A" & Rows.Count).End(xlUp)
.Range("a1:M" & Rows.Count).End(xlUp).UnMerge
End With
.Close savechanges:=False
End With
Next
Application.ScreenUpdating = True
End Sub
Sub TrimData()
On Error Resume Next
[a1:az2000] = Application.Trim([a1:az2000])
End Sub
Sub Remove_Leading_Spaces_CommSheets()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim i As Long, LR As Long, R As Range
With Sheets("Data Import")
LR = .Cells(Rows.Count, "A").End(xlUp).Row
For Each R In .Range("A1:E" & LR)
On Error Resume Next
R.Value = LTrim(R.Value)
Next R
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Sub Delete_Rows_UnwantedText()
Const sCOMPLIANCE As String = "*CONTENTS*"
Const iEXTRA_ROWS As Integer = 2
Const sAUDITORS As String = "AUDITORS"
Dim rStartCell As Range
Dim rEndCell As Range
With Sheets("Data Import").UsedRange
Set rStartCell = .Cells.Find(What:=sCOMPLIANCE, LookAt:=xlWhole)
If Not rStartCell Is Nothing Then
Set rEndCell = .Cells.Find(sAUDITORS, LookAt:=xlWhole)
If Not rEndCell Is Nothing Then
Set rEndCell = rEndCell.Offset(iEXTRA_ROWS, 0)
Range(rStartCell, rEndCell).EntireRow.Delete
Else: MsgBox "The text """ & sAUDITORS & " cannot be located"
End If
Else: MsgBox "The text """ & sCOMPLIANCE & " cannot be located"
End If
End With
End Sub
Sub AdjustRowHeight()
Dim LR As Long
With Sheets("data Import")
LR = Cells(.Rows.Count, "A").End(xlUp).Row
.Range("a1:A" & LR).EntireRow.AutoFit
End With
End Sub
Bookmarks