View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default problems getting this macro to work

Hi Ditchy,

Am Mon, 12 May 2014 01:37:38 -0700 (PDT) schrieb
:

Macro comes up with '400 error'
and does not copy and paste values & number formats to desktop with file name?
have you any more suggestions please


if you run the macro from another sheet than Worksheets(1) try:

Sub Test()
Dim myFileName As String
Dim myPath As String

myPath = "C:\Users\Ditchy\Desktop\"
myFileName = ThisWorkbook.ActiveSheet.Range("A1").Value & ".xls"

Worksheets(1).Copy
With ActiveSheet.UsedRange
.Value = .Value
End With

With ActiveWorkbook
.SaveAs Filename:=myPath & myFileName, FileFormat:=xlWorkbookNormal
.Close
End With
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional