I have tested this code on PC and works. The reason why you are having an issue is may be due to merge cells. You need to unmerge them.
Sub MergeAllWorkbooksron()
Dim MyPath As String, FolderPath As String, MyFiles() As String, SourceRcount As Long, FNum As Long
Dim SourceBoook As Workbook, BaseWks As Worksheet, Sourcerng As Range, destrng As Range, rnum As Long, CalcMode As Long
MyPath = "C:\Users\af91468.NAM\Desktop\Inspections"
If Right(MyPath, 1) <> "\" Then ' Add a slash at the end of the path if needed.
MyPath = MyPath & "\"
End If
' If there are no Excel files in the folder, exit.
FolderPath = Dir(MyPath & "*.xl*")
If FolderPath = "" Then
MsgBox "No files found"
Exit Sub
End If
' Fill the myFiles array with the list of Excel files in the search folder.
FNum = 0
Do While FolderPath <> ""
FNum = FNum + 1
ReDim Preserve MyFiles(1 To FNum)
MyFiles(FNum) = FolderPath
FolderPath = Dir()
Loop
With Application ' Set various application properties.
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
End With
' Add a new workbook with one sheet.
Set BaseWks = Workbooks.Add(xlWBATWorksheet).Worksheets(1)
rnum = 1
' Loop through all files in the myFiles array.
If FNum > 0 Then
For FNum = LBound(MyFiles) To UBound(MyFiles)
Set SourceBoook = Nothing
On Error Resume Next
Set SourceBoook = Workbooks.Open(MyPath & MyFiles(FNum))
On Error GoTo 0
If Not SourceBoook Is Nothing Then
On Error Resume Next
' Change this range to fit your own needs.
With SourceBoook.Worksheets(1)
Set Sourcerng = .Range("b1:b27")
End With
If Err.Number > 0 Then
Err.Clear
Set Sourcerng = Nothing
Else
' If source range uses all columns then skip this file.
If Sourcerng.Columns.Count >= BaseWks.Columns.Count Then
Set Sourcerng = Nothing
End If
End If
On Error GoTo 0
If Not Sourcerng Is Nothing Then
SourceRcount = Sourcerng.Rows.Count
If rnum + SourceRcount >= BaseWks.Rows.Count Then
MsgBox "There are not enough rows in the target worksheet."
BaseWks.Columns.AutoFit
SourceBoook.Close savechanges:=False
GoTo ExitTheSub
Else
' Set the destination range.
Set destrng = BaseWks.Range("A" & rnum)
' Copy the values from the source range
' to the destination range.
With Sourcerng
Set destrng = destrng.Resize(.Rows.Count, .Columns.Count)
End With
destrng.Value = Sourcerng.Value
rnum = rnum + SourceRcount
End If
End If
SourceBoook.Close savechanges:=False
End If
Next FNum
BaseWks.Columns.AutoFit
End If
ExitTheSub:
' Restore the application properties.
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = CalcMode
End With
End Sub
Bookmarks