Batch re-arrangement of excel columns with multiple files
I have a large amount of files, which need to conform to a specific layout in excel.
The problem is that in these files, columns B and C are the wrong way around.
I have created a basic Macro which quickly re-arranges the columns, however, this Macro
will only work on the current active spreadsheet.
I require a Macro which can process a large number of files, either in a folder or by user selection, and then save the newly re-arranged files with the same name and filetype (.csv).
Any help would be greatly appreciated.
Keys to the Problem Batch re-arrangement of excel columns with multiple files
Try the following code.
When executed, it will prompt you for a folder containing the files to be modified.
Choose the folder and let the code run.
It will swap columns B and C in Worksheets(1).
Dim FolderName As String
Dim FileName As StdFont
Dim Res As Long
Dim FName As String
Dim WB As Workbook
Dim WS As Worksheet
Dim LastRow As Long
Dim R As Range
Dim Temp As Variant
Res = Application.FileDialog(msoFileDialogFolderPicker).Show
If Res = 0 Then
FolderName = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1)
FName = Dir("*.cvs")
Do Until FName = vbNullString
Set WB = Workbooks.Open(FName)
Set WS = WB.Worksheets(1)
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
Set R = WS.Range("B1")
Do Until R.Row > LastRow
Temp = .Cells(1, "B")
.Cells(1, "B").Value = .Cells(1, "C")
.Cells(1, "C").Value = Temp
Set R = R(2, 1)
FName = Dir()
Manually editing the Windows registry
Manually editing the Windows registry to remove invalid MACHINE_CHECK_EXCEPTION keys is not recommended unless you are PC service professional. Incorrectly editing your registry can stop your PC from functioning and create irreversible damage to your operating system. In fact, one misplaced comma can prevent your PC from booting entirely!
Caution: Unless you an advanced PC user, we DO NOT recommend editing the Windows registry manually. Using Registry Editor incorrectly can cause serious problems that may require you to reinstall Windows. We do not guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.
To manually repair your Windows registry, first you need to create a backup by exporting a portion of the registry related to MACHINE_CHECK_EXCEPTION (eg. Windows Operating System):
- Click the Start button.
- Type "command" in the search box... DO NOT hit ENTER yet!
- While holding CTRL-Shift on your keyboard, hit ENTER.
- You will be prompted with a permission dialog box.
- Click Yes.
- A black box will open with a blinking cursor.
- Type "regedit" and hit ENTER.
- In the Registry Editor, select the Error 0x9C-related key (eg. Windows Operating System) you want to back up.
- From the File menu, choose Export.
- In the Save In list, select the folder where you want to save the Windows Operating System backup key.
- In the File Name box, type a name for your backup file, such as "Windows Operating System Backup".
- In the Export Range box, be sure that "Selected branch" is selected.
- Click Save.
- The file is then saved with a .reg file extension.
- You now have a backup of your MACHINE_CHECK_EXCEPTION-related registry entry.
Another Safe way to Fix the Problem: Batch re-arrangement of excel columns with multiple files:
How to Fix Batch re-arrangement of excel columns with multiple files with SmartPCFixer?
1. Download Error Fixer . Install it on your computer. Click Scan, and it will perform a scan for your computer. The errors will be shown in the scan result.
2. After the scan is done, you can see the errors and problems need to be repaired. Click Fix All.
3. When the Fixing part is finished, your computer has been speeded up and the errors have been removed
Related: Autologon and AutoLogonCount Parameters for Windows Unattended Setup Error Fixer,How To Resolve Cyberbit Unicode Font Does Not Return Correct Charset Problem,How To Use the Office Profile Wizard to Create an OPS File in Office XP Error Fixer,Error Sys Msg 22 Invalid period, please reenter. in MC in 4.x Solution,Why am I Getting a Upgrades from 3.01 to 3.60 or 3.01 to 3.70 Involving Serial Numbers and Revaluations Are Overstating the Valuation Entries on the Purchases Error?,How Can I Fix - Error 16389?,How to Fix - Internetopen?,Mcafee Virus Scan Online,How Can I Fix - Qos Packet Scheduler Failed?,Solution to Problem: Windows 2000 Boot Repair,How to Fix ashoutxt.dll Not Found Error,Best Method to Fix cxcore096.dll Error,Where can I Find dsauth.dll File,msde.dll Corrupted - How to Resolve,psizewizres.dll Corrupted - How to Fix,How to Download ASUS XGI Compatible Super VGA Driver Package Version R1.13.00/Driver Version 22.214.171.1240 for Windows XP 32/64 bit(WHQL),Windows Server 2003 32/64 bit(WHQL),Windows Vista 32/64 bit(WHQL),Windows Server 2008 32/64 bit(WHQL),Windows 7 32/64 bit(WHQL),Window,Download NeoMagic® MagicMedia 256AVP Display Adapter Driver,Download NVIDIA RIVA TNT2 Model 64,How to Update Realtek ALC850 AC'97 Driver V126.96.36.19900 WHQL for Windows 2000/XP/2003 & 64bit XP/2003.,How to Update Realtek LAN V6.203.0214.2008,Microsoft.PowerShell.GraphicalHost.dll Error Code Fixer
,Fix Error Code Netapi32 (4).dll
,Qa_auth_client.dll Error Code Fixer
,Fix Error Code Tdc (3).ocx
,Vwipxspx.dll Error Code Fixer
,Way to Download Toshiba Qosmio X505-Q832 Intel Wireless LAN Driver v.188.8.131.52.0.s64_wCAT,Download Toshiba Satellite C650D-ST6N02 Assist Utility v.184.108.40.206 driver,How Can You Update & Download Toshiba Satellite L645-S4026RD Value Added Package v.1.6.0130.640202 driver,Method to Download Toshiba Satellite L755-S9511D Assist Utility v.220.127.116.11 driver,Method to Download Toshiba Satellite P875-S7200 Fingerprint Utility v.2.0.0001.000408 driver,Best Way to Download NVidia GeForce 6100 VGA Driver v.304.51 Certified,How Can You Update & Download NVidia GeForce 9300/nForce 730i VGA Driver v.310.19 Certified,Method to Download NVidia GeForce GT 330M Driver v.340.65,How Can I Update & Download NVidia GeForce GTX 590 Driver v.280.26 WHQL,Method to Download NVidia Tesla C2050 Driver v.319.17
Read More: Battery charging issue [Solved],Fast Solution to Error: bing bar disappears everytime i restart - doesn't appear in add-ons manager either,How to Resolve - Bad Connection?? - My connection has slowed down an incredible amount?,How to Fix - batch file works in WinXP but not in Win7?,How Can I Fix - Bing Dynamic Theme problem?