#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Macro Help

I have created a macro that copies and pastes info from one
spreadsheet to another in the format the I need.

What I am attempting to figure out now is how can I run this macro on
multiple files. There are about 10 files per day that i need to run
this macro on and the file names will change daily. How can i have
the macro reference the desktop folder that i will store these files
in and run the macro through all files? Is this possible?

Secondly, in the macro, the last step is create an XML file out of the
spreadsheet the macro created. It always stops at this step,
prompting me to name the file. Is there a way to automatically name
the file the contents of a specific cell and save it to a destination?

I would really appreciate anyones help with this. I'm clearly not
very skilled with this, so any help you can offer would be greatly
appreciated :)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Macro Help

Just change sDir to the name of the folder you want to import from,
not sure about the XML part though (I'm still on xl2k):

Sub TryThis()
Dim myBook As Workbook, _
ThisSheet As Worksheet, _
sDir, sFile As String

sDir = "C:\FolderName\"
sFile = "*.xls"

Set ThisSheet = ActiveWorkbook.Sheets(1)

With Application
.DisplayAlerts = False
With .FileSearch
.NewSearch
.LookIn = sDir
.Filename = sFile
.MatchTextExactly = True
If .Execute < 0 Then Exit Sub
For i = 1 To .FoundFiles.Count - 1
Set myBook = Workbooks.Open(.FoundFiles(i))
With myBook
.Sheets(1).Range("A1").CurrentRegion.Copy
ThisSheet.Range("A65536").End(xlUp).Offset(1,
0).PasteSpecial
.Close
End With
Next i
End With
.DisplayAlerts = True
End With

Set myBook = Nothing
Set ThisSheet = Nothing
End Sub

Reply
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
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 02:06 PM.

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"