need assist with save as csv code

H

husky101

I have this following code
What I require is at the activeCell.SpecialCells(xlLastCell)
for it to add the next blank row to the selection.
I am having some difficulty with this.
any assistance will be greatly appreciated.
Paul

Sub SaveAsCSV()
'This macro will SAVE AS to C:\Trees folder, which must exist before
macro runs

'
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False

ActiveWorkbook.SaveAs Filename:="C:\Trees\" & "UP" & Format(Now,
"yymmddhhmm") & ".csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False


End Sub
 
B

Bob Phillips

Husky,

Please try this

Sub SaveAsCSV()
'This macro will SAVE AS to C:\Trees folder, which must exist before
macro runs

'
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell).Offset(1,0)).Copy
Workbooks.Add
ActiveSheet.Paste
Application.CutCopyMode = False

ActiveWorkbook.SaveAs Filename:="C:\Trees\" & "UP" & Format(Now,
"yymmddhhmm") & ".csv", FileFormat:=xlCSV, _
CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False


End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top