Change one cell across multiple excel files

RDeal

New Member
Joined
Apr 20, 2023
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I have 4 files saved in a folder called "Submission Tab Merge". filepath is C:\Users\RDeal\Documents\Collections\Submission Tab Merge. All four files have a tab called "Submission tab". All four files have a cell, namely D1, that I would like to update to "Q2". Currently the cell cays "Q1"
Is there a way to run something (VBA?) such that I can change all 4 files to Q2. This is a small scale for something that i plan to do with 30 files at some point.

I have little to no knowledge on VBA so please advise how to access VBA, where/how to submit the code.

I found this solution to a similiar request but could not configure the coding to work for my scenario. Making the same change to multiple Excel files

Hope someone can help.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
- To be safe, first close all your excel files
- Put the files you want to update in the folder called "Submission Tab Merge" but dont put any other excel files that you dont want to be updated.
- Create a new Excel file
- Click ALT+F11 (this will open a window where you can put your code in, this window is called VBE)
- On the left side of VBE you should see a pane called "Project", in there you should see a folder called "Microsoft Excel Objects". Right click on this folder
- From the list that pops up select Insert > Modules (a new object will appear called "Module1")
- Double click on Module1
- On the right side (the main pane) copy paste the code below:
VBA Code:
Sub UpdateFiles()
    DataDir = "C:\Users\RDeal\Documents\Collections\Submission Tab Merge\"
    ChDir (DataDir)
    Nextfile = Dir("*.xls*")
    While Nextfile <> ""
        Workbooks.Open (Nextfile)
        If Nextfile <> "Driver.xlsm" Then
            Workbooks(Nextfile).Sheets("Submission tab").Range("D1") = "Q2"
            Workbooks(Nextfile).Save
            Workbooks(Nextfile).Close
        End If
        Nextfile = Dir()
    Wend
    MsgBox "Done!"
End Sub
- Press F5 to trigger the code.

If you want to keep this new file with the code you just created, you save it anywhere you want but make sure you save as Driver.xlsm

I hope it helps.
 
Upvote 0

Forum statistics

Threads
1,224,959
Messages
6,182,000
Members
453,082
Latest member
PurpleParks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top