VBA to Concatenate across multiple workbooks


New Member
Oct 1, 2019
I'm trying to write a VBA that will concatenate the same cell across a whole folder of workbooks.

Each workbook in the file is the same, just a different topic. I have 15 different workbooks, for example I have Lion, Tiger, and Panther. In sheet 3 column D of each of these books I have some text.

I want Cat, my master book, to combine the text for each workbook in column D.

So Cat's Sheet 3 D4 will Concatenate Lion's sheet 3 D4, Tigers sheer 3 D4, and Panthers sheet 3 D4.

I would want to do this across all of sheet 3 column D (from D3 - D40), but I don't need any other column of any other sheet.

I hardly know where to start!! I'd love help, assistance, resources, or bits of code that you might find useful!!


Well-known Member
Jul 23, 2007
Hi Tooflychicken,

Welcome to MrExcel!!

Try this (just change the setting of the two variables I marked as 'Change to suit'):

Option Explicit
Sub Macro1()

    Dim strFolder As String
    Dim strExtn As String
    Dim varFileName As Variant
    Dim rngMyCell As Range
    Application.ScreenUpdating = False
    strFolder = "C:\Sxamples\" 'Directory with files. Change to suit.
    If Right(strFolder, 1) <> "\" Then
        strFolder = strFolder & "\"
    End If
    varFileName = Dir(strFolder)
    Do Until Len(varFileName) = 0
        strExtn = Trim(Right(varFileName, Len(varFileName) - InStrRev(varFileName, ".")))
        If strExtn Like "xls*" Then
            For Each rngMyCell In ThisWorkbook.Sheets("Cat").Range("D3:D40") 'Range to be linked. Change to suit.
                If Len(rngMyCell) = 0 Then
                    rngMyCell.Formula = "='" & strFolder & "[" & varFileName & "]Sheet3'!" & rngMyCell.Address
                    rngMyCell.Formula = rngMyCell.Formula & "+'" & strFolder & "[" & varFileName & "]Sheet3'!" & rngMyCell.Address
                End If
            Next rngMyCell
        End If
    varFileName = Dir
    Application.ScreenUpdating = True

End Sub


Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...