View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
jlclyde jlclyde is offline
external usenet poster
 
Posts: 410
Default Change Formula on Multiple Workbooks

Here is the macro that I have and have used to change a test folder
with test workbooks. Not all of the sheets have the same same but
they are all sheet1. Can you help me amend this to have it go to
sheet1 of each workbook?

Thanks,
Jay

Sub changeFormulas()
Dim WB As Workbook
Dim fs
Dim i As Integer

Application.DisplayAlerts = False
Application.ScreenUpdating = False

Set fs = Application.FileSearch

With fs
.LookIn = "C:\Documents and Settings\JLClyde\Desktop\Steve" '
change this to the folder you want
.Filename = "*.xls"
If .Execute 0 Then ' checks to see if there are excel files
in the folder specified
For i = 1 To .FoundFiles.Count ' for each file found
fname = .FoundFiles(i) 'sets workbook name to be
opened
Set WB = Workbooks.Open(fname) 'opens the file
With WB
Sheet1.Range("B10") = "=IF(E5=0,0,E5/C10/C13)"
.Close SaveChanges:=True
End With
Next
End If
End With

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub