Solved

Copy file and rename 110 times, increment filename by 1 each time?

Posted on 2006-07-06
2
276 Views
Last Modified: 2008-03-17
I have an Excel spreadsheet called 1.xls

Is there a bit of vbs to copy this file and call it 2.xls, then 3.xls, then 4.xls and so on - 110 times, to 110.xls?

Thanks
Lapchien
0
Comment
Question by:Lapchien
  • 2
2 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17049474
Easy

If you have the location

public sub copy100

dim fileName as string
dim outputLoc as string
dim lngLc as long

fileName = "C:\xxx\1.xls"
outputLoc = "C:\xxx\"

for lngLC = 2 to 110
    filecopy filename, outputLoc & lnglc & ".xls"
next lngLc

end sub
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17049484
Sory the sub should be public sub copy100 ()

This goes through the numbers in the selected range and copies from the fileName to the outputLocation - and the name of the file is just the number - if you want it to be numbered 002 to 110 then you would use a format statement in th filecopy
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now