Eroor 76 Path not found

Closed
Swe - Mar 30, 2009 at 09:22 AM
meltakeall Posts 22 Registration date Tuesday August 19, 2008 Status Member Last seen June 10, 2009 - Mar 31, 2009 at 03:38 AM
Hello,
Hi,

I an trying to write a macro to copy the last row from one workboo1 and paste it in workbook2. After pasting it needs to rename the second workbook in a new folder.
Folling is the code.I am experiencing some problems like.
error 76 Path not found.
When i am trying to create a new folder.First i need to check if that folder exists or not.if it does it needs to save this workbook2 in that folder,otherwise create the new folder with that name and then save it.
Please help.






Code:
Sub Transferdata()
Workbooks.Open Filename:="C:\Testmacro\Sweweeklstatusrep.xls"


Set c = Workbooks("Sweweeklstatusrep").Sheets("sheet1") 'This is the workbook you want to copy the data from.
Set d = Workbooks("SweAorSummary.xls").Sheets("sheet1") 'This is the destination workbook

Dim LastRow
Dim NewRow

'column B in both workbooks to find the last row.
LastRow = c.Range("B65536").End(xlUp).Row
NewRow = d.Range("B65536").End(xlUp).Row


'The destination workbook has to find the last row, and then paste the data below it.
'That is why +1 is used. Otherwise, you would write over the existing data.
'd.Rows(NewRow + 1).Value = c.Rows(LastRow).Value
d.Range("B" & NewRow + 1, "E" & NewRow + 1).Value = c.Range("B" & LastRow, "E" & LastRow).Value

'Acitvate the workbook you just copied the new line to.
Workbooks("SweAorSummary.xls").Sheets("sheet1").Activate

'Find the last row of your new line and get the date.
Dim GetDate
Dim MyDate
'Dim sFileName As String
Dim sPath As String

GetDate = d.Range("E65536").End(xlUp).Row
MyDate = d.Range("E" & GetDate).Value

'Const sPath As String = "C:\Testmacro\MyDate"
'sFileName = Range("A1").Value & Range("a2").Value
sPath As String
sPath = "C:\Testmacro\" & MyDate
If Len(Dir(sPath)) = 0 Then
MkDir sPath
ChDir sPath

'I want this workbook to be saved in the new folder.
Workbooks("SweAorSummary.xls").SaveAs Filename:="AOR Summary" & MyDate & ".xls", FileFormat:=xlWorkbookNormal
End If

End Sub
Related:

1 response

meltakeall Posts 22 Registration date Tuesday August 19, 2008 Status Member Last seen June 10, 2009 5
Mar 31, 2009 at 03:38 AM
hi,
try this link to see if it can help you:
https://support.tabs3.com/main/r10650.htm
0