View Full Version : Excel VBA
Ok I have Excel exporting a snippet of data in an Excel Sheet to another Excel sheet by way of VBA.
Problem is.. the current workbook closes when the Macro runs the Export & re-opens as the Exported file.
Anyone know how I can stop this behavior ?
thx
/Paul.
Any chance you could upload some code Paul? txt file would do. :)
This is what i tried...
Sub testexport()
'
' export Macro
Range("c7:e17").Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
ActiveWorkbook.SaveAs Filename:= _
"C:\test.csv" _
, FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
ActiveWorkbook.Close = False
Application.DisplayAlerts = True
End Sub
Without knowing too much about what you want to do, I assume you want it to create the new file but not show it.
Try this:
Sub Exp()
Dim FileName As String
Dim ce As Range
FileName = ThisWorkbook.Path & "\Test.csv"
Open FileName For Output As #1
For Each ce In Range("C7:E17")
Write #1, ce.Value
Next ce
Close #1
End Sub
Only thing is, this will post the range as a list in the first column, dont know if thats what you want or not. :cool:
Your a star :thumb:
That solved the closing down & reopening worked perfect in that respect :)
I just need to modify a bit now so it sends out the Formulas references as text and jobs a good un.
thx again :thumb:
-----------------------
/edit doh ... i opened the wrong file called test lol
I see what you mean by putting in in one column, not really what I am after but your supplied info might be enough for me to work from and come up with something.
I will see what I can come up with :)
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.