In this post we learn how to combine all the Excel files in a given folder using VBA macros. The macro triggers a dialog box to select a folder from the local drive, and then loops through the workbooks in that folder to copy the contents to the recipient workbook. That includes all the worksheets in each of the workbooks within the target folder. Use the code below to combine all Excel files in a folder into one single workbook.
Saturday, August 20, 2022
Tuesday, April 5, 2022
Protect Selected Workbooks Excel VBA Macro
In this post we learn how to protect all selected workbooks in Excel using VBA macros. The macro protects the workbook structure and the contents of each worksheet with a password. Alternatively, or additionally, another line of code can be added to encrypt the file with that password. The macro initially asks the user to set a password, and then displays a dialog to select the files. The same code can easily be adapted to unprotect the workbooks with a password.
Thursday, February 17, 2022
Compare Two Workbooks Excel VBA Macro
In this post we see how to compare two Excel workbooks with VBA macros. The macro checks if the number of worksheets matches, then compares the worksheet names and the contents in the sheets with the same name (this last piece of code has been covered in this other post: Compare Two Worksheets). Whenever there is a mismatch, it highlights the sheet or cells with different values in yellow, and displays a message with cell and worksheet (this could also be copied to a separate sheet instead). Note that the macro compares the workbook with the macro (ThisWorkbook) and a second open workbook. Optionally, a dialog to open the second file, or even the two workbooks could be implemented at the start if need be.
Sunday, December 12, 2021
Combine All Open Workbooks Excel VBA Macro
We often need to gather data spread across
several Excel workbooks. The following VBA macro combines all open workbooks
into just one. The final number of worksheets will be the sum of sheets across
all open workbooks. We may want to add code to close the workbooks when done; we
can do that simply adding wb.Close within the IF statement.
Friday, September 24, 2021
Separate Sheets Into Workbooks Excel VBA Macro
This macro example separates sheets into new workbooks, keeping the original workbook. Each new workbook takes the name of the sheet and contains one single sheet with its original contents.
Friday, September 18, 2020
Friday, July 10, 2020
Open Workbook Safely Excel VBA Macro
Monday, July 6, 2020
List Defined Names Excel VBA Macro
Popular Posts
-
In a previous post , we have seen how to send an email from Excel (via Outlook) using VBA macros. We can add as many recipients as needed se...
-
We can integrate Excel with other Microsoft Office applications using VBA. In this post we are going to see how to send an email from Excel ...
-
In this macro example, we compare two worksheets with data from two different versions of the same data set. Thus, we can see if there are a...
-
Excel offers filter options to easily narrow down the data. This macro example activates the filter option in VBA and copies the filtered da...
-
In this post we learn how to upload or export data from Excel to Google Sheets using VBA macros. The macro sends a HTTP request to POST the ...
-
In this post we see how to compare two Excel workbooks with VBA macros. The macro checks if the number of worksheets matches, then compares ...
-
In a previous post we saw how to Compare Two Worksheets in Excel using VBA macros. In this post we see how to compare two columns with data...
-
This macro runs a clock timer in Excel. The user can start/stop the time, and the clock shows minutes and seconds. It is a simple example ...
-
This macro example separates sheets into new workbooks, keeping the original workbook. Each new workbook takes the name of the sheet and con...
-
In this post we see how to delete rows based on given criteria in Excel using VBA macros. The macro loops through each row with content in t...