LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default RP - Add contents of cell A1 in all workbooks within a folder

Thanks for the follow-up Bob. I ran it, but I get an "Argument not
optional" error on the line
If FileCountOK Then
Am I doing something wrong? I'm runnung the ProcessFiles sub. Thanks!

"Bob Phillips" wrote in message
...
Private Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As Long

Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Sub ProcessFiles()
Dim FSO As ObjectDim fldr As Object
Dim sFolder As String
Dim Folder As Object


Set FSO = CreateObject("Scripting.FileSystemObject")

sFolder = "C:\evaluation"

If sFolder < "" Then
Set Folder = FSO.GetFolder(sFolder)
If FileCountOK Then
StephsMacro
End If
End If ' sFolder < ""

End Sub

Function FileCountOK(pzFolder as Object)
Dim i As Long
Dim file As Object
Dim Files As Object

FileCountOK = TRUE
Set Files = pzFolder.Files
For Each file In Files
If file.Type = "Microsoft Excel Worksheet" Then
i=i+1
Workbooks.Open Filename:=file.Path
With ActiveWorkbook
FileCountOK = .Activesheet.Range("AQ1").Value = 1
.Close savechanges:=False
If Not FileCountOK The Exit Function
End With
End If
Next file

End Function


--

HTH

RP



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
add a folder to c:\ drive from cell A1 contents... [email protected] Excel Discussion (Misc queries) 1 July 25th 06 09:48 PM
Copy a cell to all workbooks within a folder. Andy T Excel Discussion (Misc queries) 16 February 2nd 05 11:14 PM
Add contents of A1 in all workbooks within a folder Steph[_3_] Excel Programming 18 October 4th 04 11:52 PM
Using Cell Contents to Reference External Workbooks SowBelly Excel Programming 2 July 31st 04 01:55 AM
Loop through workbooks in a folder and return the value of cell M43 RockNRoll[_2_] Excel Programming 1 January 21st 04 07:46 PM


All times are GMT +1. The time now is 03:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"