473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Reformatting Excel Files and sending output to notepad

Hi All

Been attempting my spreadsheet conversion to notepad all morning without any luck and now very frustrated

Could some of you good people in here help out if possible

It seems very simple but I cant get my head round it. I have 56 large files in a directory which I need to reformat etc into a csv/notepad format. All 56 files that are in excel format need to be in this one humongous csv file

I have also attached input and output files below in the zip file

Any helpers?

Thanks

Rich
Attached Files
File Type: zip input.zip (244.5 KB, 98 views)
Oct 12 '08 #1
1 1669
ok getting somewhere slowly......how do i loop through within a selected directory to look at all files within a directory?

[HTML]Sub WriteCSV()
Const Delimiter = ";"
Const Delimiter2 = "#"
Const Delimiter3 = " "
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const MyPath = "C:\Users\xxxx\Desktop\" 'Put you path of where you want it saved here
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Set fswrite = CreateObject("Scripting.FileSystemObject")
WriteFileName = ThisWorkbook.Name & ".csv"

'open files
WritePathName = MyPath + WriteFileName
fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(WritePathName)
Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault)
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = 1 To LastRow
For colcount = 1 To 14
If colcount = 1 Then
outputline = Cells(RowCount, colcount)
ElseIf colcount = 2 Then
outputline = outputline & Delimiter2 & Cells(RowCount, colcount)
ElseIf colcount = 3 Then
outputline = outputline & Delimiter2 & Cells(RowCount, colcount)
ElseIf colcount = 5 Then
outputline = outputline & Delimiter2 & Format(Cells(RowCount, colcount), shortdate)
ElseIf colcount = 6 Then
outputline = outputline & Delimiter3 & Format(Cells(RowCount, colcount), longtime)
ElseIf colcount = 9 Then
outputline = outputline & Delimiter & Cells(RowCount, colcount)
Else
outputline = outputline
End If
Next colcount
tswrite.writeline outputline
Next RowCount
tswrite.Close
End Sub[/HTML]
Oct 12 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: cv | last post by:
Hi all, I have to copy two set of data from 2 files(notepad/excel) say, products and their corresponding prices to list/textarea/table. I should be able to retrieve the product and corresponding...
2
by: Bryan Harrington | last post by:
Hello all.. I'm working on some reports, and have added the ability to "download" the reports to excel. Not a big deal, fairly straight forward. However, PHB wants to be able to create some pivot...
0
by: Oci-One Kanubi | last post by:
Everything works fine in Access, but when I double-click on the resultant Excel files the first one opens correctly, but subsequent ones, and any other Excel files I try to open, fail to display at...
9
by: Sandy | last post by:
can mfc application, send text data to opened notepad file in desktop?(live transfer of data) . can anybody help
3
by: Chris Lane | last post by:
Hi, This is super annoying FrontPage like behavior. Does anybody know how I can stop the Visual Studio.NET IDE from reformatting my HTML? Thank You
9
by: hari krishna | last post by:
hi, I want to send the data from dataset information to Excel through ASP.Net. there will be no XL installed on web server. web server is win 2000 server machine. I am using visual basic code in...
1
by: Aiysha | last post by:
Hi, I want to take cotrol of notepad from excel (through VB programming). I have .prn files which have to opened in notepad and then I have to save these .prn files in .sim , all files format. ...
4
by: michael.pearmain | last post by:
Hi Experts, Looking for a very quick bit on of advice on how to make some python code run. I'm a newbie to both VBA and Python, so i apologise if this is very easy but i'm about to tear my hair...
18
by: Paul Lautman | last post by:
JRough wrote: What do you mean by "redirect the output to Excel"??? Excel isn't a location, it's a spreadsheet program that some (but not all users) will have on their machine. BTW, Location:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.