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
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,215,055
Messages
6,122,902
Members
449,097
Latest member
dbomb1414

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