The world's most tricky macro.

Kespallo

New Member
Joined
Nov 30, 2014
Messages
1
Hi guys, I'm new to VBA and Excel, but I'm facing a real problem while trying to learn and create a macro.
Well, the macro I have to make is very difficult, since excel and vba are a new world for me, eventhough I know a bit of VB.net, I feel completely lost using this program.


Here is the challenge!!
I have to make a macro that will do a few procedures... just being a bit modest...


1º: It has to convert all files in a specific folder with the extension .csv to xlsx without changing the filename.
2º: Add the date (DD,MM,YYYY) to those files and all the other ones in the same folder.
3º: Save those files in another folder. BUT... Here is the tricky part...
For example:
The folder A (The folder with all the .csv files) will have a whole bunch of other files together with different extensions, names and etc. But the macro gonna have to change the filename of all files that begins with "FTE".
I have no idea how to do this, like I said, I'm very new to VBA.
A example of what I'm saying:

(This is the Folder A and all it's files)
FTE_blahblahblah.csv
FTE_blah2.xls
FTE_blah3.xlsx

<tbody>
</tbody>


I'll need to change all files that begins with "FTE" to another name and save into a different folder.

It will look like this:
FTE_blahblahblah.csv --> Tacos_blahblahblah - 30-11-2014.csv

(This is the Folder B and all it's files)
Tacos_blahblahblah - 30-11-2014.xlsx
Tacos_blah2 - 30-11-2014.xls
Tacos_blah3 - 30-11-2014.xlsx

<tbody>
</tbody>

And to finish it like a boss, there has to be another directory to save the backup of these "new files".



I know that I'm asking too much, and I don't even know if this is possible of doing on the Excel, but this is something that I really need and I have no one to help me solve it. So, if someone here can help me kill this boss, it's gonna be awesome!!!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hello world! :)

My answer is premised on your programming experience in VB.NET. Using VB.NET, all the files in the specific folder can get with System.IO.Directory.GetFiles.

Code:
Dim files As String() = System.IO.Directory.GetFiles( _
    "C:\The folder A", "*", System.IO.SearchOption.AllDirectories)

In VBA, check Dir function.

Code:
Dir[(pathname[, attributes])]

I beleive that FileCopy Statement also help your problem.

Code:
FileCopy source, destination

About String Manipulation and a Loop Control Structure, no big difference between VB.NET and VBA. (Actually VB.NET is a little bit handy and powerful.)

Good luck!
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top