excute uniform macro on several sheets at once

abdul hafeel

New Member
Joined
Oct 14, 2006
Messages
9
I need to run a uniform macro on several stored in different folders cocurrently. Can this be done

Thanks in advance
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
abdul hafeel,

That would depend on your definition of concurrently.

If you think concurrently means that the same operations are performed at the exact same time on more than one object, I'd have to say no. Even if you were able to start concurrent sessions of Excel at the exact same time and beging execution at the exact same time, the sessions will still be given attention by your computer's processor in a serial manner making one of the sessions end before the other, etc.

If you mean you want to run the same macro on workbooks stored in different locations, I'd have to say probably yes. As long as you don't mean you also want to do something at the same time to more than one of the workbooks.

Dufus
 
Upvote 0
Hi Dufus

What I meant was to run the same macro of different closed worksheet, one after the other. So I agree It's not a concurrent operation. Sorry for the confusion. Could you pls help on this.

Thanks in advance.
Cheers
 
Upvote 0
I suggest you put a new sheet called Files and in column A list out all the files you want to do the macro on (full path and name) and then run the folowing code. Substitute your macro's name in the call Macro part.

Code:
Sub RunAll()

Dim tFile As String
Dim tBook As String
Dim i As Long

For i = 1 To Sheets("Files").UsedRange.Rows.Count 'Files is the sheet with the list of files

    tFile = Sheets("Files").Range("A" & i).Value
        
        If tFile <> "" Then

            Workbooks.Open(tFile).Activate
            tBook = ActiveWorkbook.Name
            Call Macro 'your macro name
            Workbooks(tBook).Close SaveChanges:=True
            
        End If

Next i

End Sub

Hope it helps
 
Upvote 0
Well I am working on citrix & need to update files on a remote machine. Having to open the files will take time. My question is instead of having to use the .open command is there a way of running a macro on a closed excel file.

Can I have the VBA/MAcro code on the main execl file which will list all the file paths & names of the various excel files that need to be updated and simply pressing a button will update these files even when they are closed?

Cheers
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,387
Members
448,956
Latest member
JPav

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