help with macro opening other workbooks and running macros in them

emantzoo

Board Regular
Joined
Nov 6, 2013
Messages
80
I have this code to loop through some cells of a workbook (wb), and if they are formatted as bold, to open a specific file (wb1), save it with another filename (FinFil) and run macro1 in it. Macro1 closes FinFil .
It works ok with the first bold cell, but then it stops...

any ideas?

Code:
 With wb
        .Sheets(1).Calculate
        For Each cel In .Sheets(1).Range("f12:f1111")
            If Trim(cel) <> "" And cel.Font.Bold = True Then
                filName = .Sheets(1).Range("b10") & "\" & .Sheets(1).Range("b14")
                Select Case Dir(filName)
                    Case ""
                        MsgBox "Could not find file: " & filName
                    Case Else
                    Set wb1 = Workbooks.Open(filName)
                        With wb1
                        
                            FinFil = .Sheets("PROFILE").Range("c1")
                            .SaveAs Filename:=FinFil, FileFormat:=52
                                          
                       
                            Application.Run ("'" & FinFil & "'!macro1")


                        Set wb1 = Nothing
                        
                        End With
             
                End Select
            End If
         
        Next cel
    End With
 

Some videos you may like

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.

Watch MrExcel Video

Forum statistics

Threads
1,122,554
Messages
5,596,814
Members
414,104
Latest member
imamalidadashzada

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
Top