Automated Reformat

zubo

New Member
Joined
Aug 3, 2011
Messages
2
Hi All

My brain has gone to sleep so apologies for a really dumb question:

I'm looking at the best way of achieving some simple automation....

I'm trying to integrate shared data between two applications and have no way of changing those apps and export/import using csv is the only method available.

So app A formats data for export in each row as a, b, c

and app B requires data as a,,,c,b

What would be the best way of automating this?

Hope you can help,

thanks

george
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Welcome to the board

I created a spreadsheet with some code in it, and a folder saved in the same location, named "csv folder". The idea is that EVERY file saved in the csv folder has the columns moved around when this macro is run from the spreadsheet. CSVs don't need to be open, and there can be any amount processed at the same time

WARNING! This will change the CSVs and save the changes, there will be no undo. If you run this macro twice on the only version of your files, you will lose all your data! Make sure you understand exactly what this code is doing before you use it

Code:
Sub insertColsToAllFiles()

Dim srcFolder As String, sourceFileNames As String
 
Application.ScreenUpdating = False
srcFolder = ThisWorkbook.Path & "\csv folder\"
sourceFileNames = Dir(srcFolder & "*.csv")
 
Do While sourceFileNames <> ""
    
    With Workbooks.Open(srcFolder & sourceFileNames)
        .Sheets(1).Columns("B").Cut Destination:=.Sheets(1).Columns("E")
        .Sheets(1).Columns("C").Cut Destination:=.Sheets(1).Columns("D")
        .Close savechanges:=True
    End With

    sourceFileNames = Dir
Loop
 
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hey smug git.... you are most definitely some kind of genius...

that is exactly what I need...

owe you one,

george
 
Upvote 0
aww that's the nicest thing anyone's said to me all day :)

thanks for the feedback, its always appreciated
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,463
Members
452,915
Latest member
hannnahheileen

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