Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Me Me is offline
external usenet poster
 
Posts: 67
Default Saving in csv file after removing unused cells

In one worksheet, I filtered out bunch of calculated data from several other
worksheet. Altough cell contents are "" after the first 10 row, when I try to
save file as csv or text, I end up having a big file with 1000s of lines with
comma sepateded blank values. Is there any way, I can eliminate this using
macro or visual basic.

Best Regards,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 417
Default Saving in csv file after removing unused cells

If you have done lots of editing, running of macros, etc. on the active
worksheet, then its UsedRange property will still include a lot of "empty"
cells that will be eliminated after the workbook is saved.

Try copying only the cells that still have data that you want to export to
the CSV file to a new worksheet in a new workbook, then saving.

--
Regards,
Bill Renaud



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Saving in csv file after removing unused cells

Why do you edit the file with notepad and delete the blank lines. If it is
only one worksheet it doesn't pay to write code to fix a one time problem.

"Bill Renaud" wrote:

If you have done lots of editing, running of macros, etc. on the active
worksheet, then its UsedRange property will still include a lot of "empty"
cells that will be eliminated after the workbook is saved.

Try copying only the cells that still have data that you want to export to
the CSV file to a new worksheet in a new workbook, then saving.

--
Regards,
Bill Renaud




  #4   Report Post  
Posted to microsoft.public.excel.programming
Me Me is offline
external usenet poster
 
Posts: 67
Default Saving in csv file after removing unused cells

thank you for your quick reply. Let me explain the problem more clearly.

There are several worksheets which gets filtered out bunch of calculated
data from several other. Basicly each worksheet gets data from main data
worksheet with certain categories. (such as Product Name and Date Range).

Then a macro runs and selects each product worksheets and saves as comma
separated "product-name-mmddyy.txt" Since each worksheet pages covers 1400
rows, each row has formula and results of those formula mostly are ' "" '.
Only the first 10-100 row has values.

Saving each pages manually and then deleting unnecessary part of data is
time consuming especially when I am trying to do this every day.

So What I want to do is
either, selecting the last result value row number which is different than '
"" ' and selecting this range and saving this range as a csv file using VB.

or

deleting the area which results are "", then save the files as csv using VB

or some other way that currently I can not think of.

I really appreciate any helps. Thanks



Best Regards

"Joel" wrote:

Why do you edit the file with notepad and delete the blank lines. If it is
only one worksheet it doesn't pay to write code to fix a one time problem.

"Bill Renaud" wrote:

If you have done lots of editing, running of macros, etc. on the active
worksheet, then its UsedRange property will still include a lot of "empty"
cells that will be eliminated after the workbook is saved.

Try copying only the cells that still have data that you want to export to
the CSV file to a new worksheet in a new workbook, then saving.

--
Regards,
Bill Renaud




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Saving in csv file after removing unused cells

Does this simple code help?

Sub removequotes()

Cells.Replace _
What:=Chr(34) & Chr(34), Replacement:="", lookat:=xlWhole
End Sub

"me" wrote:

thank you for your quick reply. Let me explain the problem more clearly.

There are several worksheets which gets filtered out bunch of calculated
data from several other. Basicly each worksheet gets data from main data
worksheet with certain categories. (such as Product Name and Date Range).

Then a macro runs and selects each product worksheets and saves as comma
separated "product-name-mmddyy.txt" Since each worksheet pages covers 1400
rows, each row has formula and results of those formula mostly are ' "" '.
Only the first 10-100 row has values.

Saving each pages manually and then deleting unnecessary part of data is
time consuming especially when I am trying to do this every day.

So What I want to do is
either, selecting the last result value row number which is different than '
"" ' and selecting this range and saving this range as a csv file using VB.

or

deleting the area which results are "", then save the files as csv using VB

or some other way that currently I can not think of.

I really appreciate any helps. Thanks



Best Regards

"Joel" wrote:

Why do you edit the file with notepad and delete the blank lines. If it is
only one worksheet it doesn't pay to write code to fix a one time problem.

"Bill Renaud" wrote:

If you have done lots of editing, running of macros, etc. on the active
worksheet, then its UsedRange property will still include a lot of "empty"
cells that will be eliminated after the workbook is saved.

Try copying only the cells that still have data that you want to export to
the CSV file to a new worksheet in a new workbook, then saving.

--
Regards,
Bill Renaud






  #6   Report Post  
Posted to microsoft.public.excel.programming
Me Me is offline
external usenet poster
 
Posts: 67
Default Saving in csv file after removing unused cells

Thank you for the code. Altough it was useful but it did not work for me. I
can send a simplified file that explain the situation. I am not sure, if I
can attach a file here. Let me explain litle more in detail.

Sheet1 : I have two bottons for a macro.

Sub Killfile()
Dim MyFile As String
On Error Resume Next 'On hitting errors, code resumes next code
MyFile = "C:\teama\data\teamA.txt"
Kill MyFile

On Error Resume Next 'On hitting errors, code resumes next code
MyFile = "C:\teamb\data\teamB.txt"
Kill MyFile

End Sub

Sub SaveAsText()

' Save Open files as csv in MS-DOS format
Sheets("teamA").Select
ChDir "C:\teama\data"
ActiveWorkbook.SaveAs Filename:= _
"C:\teama\data\teamA.txt", FileFormat _
:=xlCSV, CreateBackup:=False


' Save Open files as csv in MS-DOS format
Sheets("teamB").Select
ActiveWorkbook.SaveAs Filename:= _
"C:\teama\data\teamB.txt", FileFormat _
:=xlCSV, CreateBackup:=False
End Sub




in "data" worksheet, I have following fields and data

product Rq date Sale Person Sale Date Price Sales ID Commission Data2 Data3
-


In C-teamA and C-teamB, certain criteria are selected and filetered data
from "data worksheet"

In teamA worksheet
I have following simple link from C-teamA
In cell A1 to I1400
=IF('C-TeamA'!B2<"",'C-TeamA'!B2,"")

So I want to save teamA, teamB...etc into csv text file. If any help, it
will greatly appricated.





"Joel" wrote:

Does this simple code help?

Sub removequotes()

Cells.Replace _
What:=Chr(34) & Chr(34), Replacement:="", lookat:=xlWhole
End Sub

"me" wrote:

thank you for your quick reply. Let me explain the problem more clearly.

There are several worksheets which gets filtered out bunch of calculated
data from several other. Basicly each worksheet gets data from main data
worksheet with certain categories. (such as Product Name and Date Range).

Then a macro runs and selects each product worksheets and saves as comma
separated "product-name-mmddyy.txt" Since each worksheet pages covers 1400
rows, each row has formula and results of those formula mostly are ' "" '.
Only the first 10-100 row has values.

Saving each pages manually and then deleting unnecessary part of data is
time consuming especially when I am trying to do this every day.

So What I want to do is
either, selecting the last result value row number which is different than '
"" ' and selecting this range and saving this range as a csv file using VB.

or

deleting the area which results are "", then save the files as csv using VB

or some other way that currently I can not think of.

I really appreciate any helps. Thanks



Best Regards

"Joel" wrote:

Why do you edit the file with notepad and delete the blank lines. If it is
only one worksheet it doesn't pay to write code to fix a one time problem.

"Bill Renaud" wrote:

If you have done lots of editing, running of macros, etc. on the active
worksheet, then its UsedRange property will still include a lot of "empty"
cells that will be eliminated after the workbook is saved.

Try copying only the cells that still have data that you want to export to
the CSV file to a new worksheet in a new workbook, then saving.

--
Regards,
Bill Renaud




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting/removing unused rows in a worksheet Tom Excel Discussion (Misc queries) 3 November 25th 09 04:58 PM
Saving file without empty cells iashorty Excel Discussion (Misc queries) 2 July 10th 08 01:37 PM
what to do with unused cells B Excel Worksheet Functions 1 June 22nd 06 12:09 AM
Removing unused reference KarenH Excel Programming 6 April 6th 06 05:11 PM
Removing unused or blank rows and columns Mark F Excel Discussion (Misc queries) 2 December 23rd 04 02:39 AM


All times are GMT +1. The time now is 05:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"