View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Copy part of worksheet in VBA

Btw: You not Set a string

Try this

Sub Save_Range()
Dim source As Range
Dim dest As Workbook
Dim strdate As String
Dim Newname As String

Newname = Sheets("Jourer").Range("I2").Value
Set source = Range("C5:K34") ' this use the cells on the activesheet

Application.ScreenUpdating = False
Set dest = Workbooks.Add(xlWBATWorksheet)
source.Copy
With dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
' Paste:=8 will copy the column width in Excel 2000 and higher
' If you use Excel 97 use the other example
.Cells(1).PasteSpecial xlPasteValues, , False, False
.Cells(1).PasteSpecial xlPasteFormats, , False, False
.Cells(1).Select
Application.CutCopyMode = False
End With

strdate = Format(Now, "dd-mm-yy h-mm-ss")
With dest
.SaveAs Newname & " " & strdate & ".xls"
.Close False
End With
Application.ScreenUpdating = True
End Sub




--
Regards Ron De Bruin
http://www.rondebruin.nl



"Ruatha" wrote in message
...

Hi, I'm here to ask for even more.
Can I get the text in cell "I2" into the filenamne.

As in (approximation) :
Dim Newname as string
Set newname = ActiveWorkBook.Sheets("Jourer").range("I2").Value

and add that to the filename.

Everything I try it says "Object Required (Error 424)"..


--
Ruatha
------------------------------------------------------------------------
Ruatha's Profile: http://www.excelforum.com/member.php...o&userid=31083
View this thread: http://www.excelforum.com/showthread...hreadid=551749