View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Office_Novice Office_Novice is offline
external usenet poster
 
Posts: 245
Default Clear 4 cells in every file in folder

I guess my previous post was a little Hastey this works well

Sub DeleteThatRange()
Dim FolderPath As String
Dim objFSO As Object
Dim objFolder As Object
Dim colFiles As Object
Dim objFile As Variant
Dim msXL As Object
Dim ws As Worksheet

'On Error Resume Next

FolderPath = "C:\Documents and Settings\Desktop\ABC Folder"
Set msXL = CreateObject("Excel.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FolderPath)
Set colFiles = objFolder.Files



For Each objFile In colFiles
Workbooks.Open (objFile)
msXL.Visible = True
For Each ws In ActiveWorkbook.Worksheets
ws.Activate
Range("C1:C4").ClearContents
Next
ActiveWorkbook.Close SaveChanges:=True
Next
End Sub




"Diddy" wrote:

Hi everyone,

I wonder if anyone could help me with this please?

I would like to clear the contents of cells C1-C4 in all the sheets in all
the files in one folder.

I'm only just getting to grips with looping through and just can't work this
out.

Many thanks
--
Deirdre