Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA help to output a file



Hi, I need help in getting the following accomplished and would
appreciate any help you can give:

I have a spreadsheet that I want to write out to a file. In this
spreadsheet if there is a 0 in a certain cell then I don't want that
entire row written to the file but if there is an amount there I want
the entire row written out to the file.

Can anyone help? Thank you so much.

Paula

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default VBA help to output a file

one way (I assume that by "write out to a file" you mean a csv file, and
that the "certain cell" is in column A - adjust as necessary):

Public Sub CopyNonZeroToFile()
Const sFileName As String = "test.csv"
Dim rCrit As Range
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
With ActiveSheet
Set rCrit = .Cells(1, .Columns.Count).End( _
xlToLeft).Offset(0, 2).Resize(2, 1)
rCrit(2).Formula = "=A2<0"
Sheets.Add
.Range("A1").CurrentRegion.AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=rCrit, _
CopyToRange:=ActiveSheet.Range("A1"), _
Unique:=False
rCrit.Clear
End With
ActiveSheet.Move
With ActiveWorkbook
.SaveAs Filename:=sFileName, _
FileFormat:=xlCSV, _
CreateBackup:=False
.Close SaveChanges:=False
End With
With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub

In article ,
Paula Weill wrote:

Hi, I need help in getting the following accomplished and would
appreciate any help you can give:

I have a spreadsheet that I want to write out to a file. In this
spreadsheet if there is a 0 in a certain cell then I don't want that
entire row written to the file but if there is an amount there I want
the entire row written out to the file.

Can anyone help? Thank you so much.

Paula

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA help to output a file

When I run this macro I get the following error:

"Run time error 1004" "The exact range has a missing or illegal field
name"

The column that might have a zero in it is column F. And yes, I am
writing a .csv file. Thanks for any more info you can give!



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Checkbox - Output results to a csv file Ephraim Excel Worksheet Functions 4 March 31st 10 03:51 PM
output to the same line in a Text file? Bernard Excel Discussion (Misc queries) 2 November 25th 09 08:12 PM
Need Help With Loop That Creates Output File Jenny Marlow Excel Discussion (Misc queries) 0 April 23rd 08 11:23 PM
Open a print output sent to file Ted Johnston Excel Discussion (Misc queries) 0 February 24th 06 10:10 AM
Trying to protect output file with Macro Vasant Nanavati Excel Programming 0 June 2nd 04 01:23 AM


All times are GMT +1. The time now is 03:09 PM.

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

About Us

"It's about Microsoft Excel"