try this see if it helps
Function file_exists(fl_path As String) As Boolean
If Dir(fl_path) <> "" And fl_path <> "" Then
file_exists = True
Else
file_exists = False
End If
End Function
Sub tests()
Dim finame As String
Dim wkb As Workbook
With Sheets("Feedback")
finame = .Range("P1").Value & "\" & .Range("P2").Value & ".xlsx"
End With
If file_exists(finame) = False Then
MsgBox "Create fil.,.."
Exit Sub
End If
Set wkb = Workbooks.Open(finame)
ThisWorkbook.Sheets("Feedback").Copy After:=wkb.Sheets(Sheets.Count)
wkb.Save
wkb.Close
End Sub
On Thu, May 2, 2013 at 3:42 PM, santosh subudhi <
[email protected]> wrote:
> Hello Ravi,
>
> The code provided by you is trying to replace book 2.
>
> However I want the code to copy the sheet "Feedback" of Book 1 and paste
> it with the name provided in cell P2 in book2 as the last sheet and close
> the book2 automatically.
>
> If the book2 is not available in the path provided in P1 of Book1 it
> should show a message asking the user to create a file with the above name
> run the macro(button in sheet1 of book1).
> Attaching the book1 with code provided by you.
>
> Hope I am clear with my query.
> --
> Regards
> Santosh
> [email protected]
>
>
> Date: Wed, 1 May 2013 03:56:04 -0700
> From: [email protected]
> Subject: Re: $$Excel-Macros$$ copy the active worksheet and paste it to
> another workbook in a given path.
> To: [email protected]
>
>
> here is the code...
> Sub filecopy()
> sheetname = ActiveWorkbook.ActiveSheet.Range("a16")
> Path = ActiveWorkbook.ActiveSheet.Range("a15")
>
> Sheets("Sheet1").Select
> Sheets("Sheet1").Copy
> ActiveWorkbook.SaveAs Path & "\" & "book2", FileFormat:=56
> ActiveSheet.Name = sheetname
> ActiveWorkbook.Sheets(sheetname).Range("a15:a16") = ""
> ActiveWorkbook.Save
> ActiveWorkbook.Close
>
> End Sub
>
>
> --- On *Tue, 4/30/13, santosh subudhi <[email protected]>*wrote:
>
>
> From: santosh subudhi <[email protected]>
> Subject: $$Excel-Macros$$ copy the active worksheet and paste it to
> another workbook in a given path.
> To: "excel-macros" <[email protected]>
> Date: Tuesday, April 30, 2013, 11:48 PM
>
> Hello Team,
>
> I need a code that will copy the active worksheet and paste it to another
> workbook in a given path.
>
> The path will be in one of the cells of the active worksheet.
>
> For example my active workbook name is book1 and I want the sheet 1 of
> book 1 to be copied and save it in another workbook named book2 as the last
> worksheet. The path of book 2 is in cell A15 of Sheet 1 of book 1.
>
> Once the sheet is moved to book 2 the sheet name should also be
> changed.The name of the sheet is saved in Cell A16 of sheet1 of book1.
>
> --
> Regards
> Santosh
> [email protected]<http:///mc/[email protected]>
>
> --
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>
> NOTE : Don't ever post confidential data in a workbook. Forum owners and
> members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/excel-macros?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
*Regards*
* *
*Ashish Koul*
*Visit*
*My Excel Blog <http://www.excelvbamacros.com/>*
Like Us on
Facebook<http://www.facebook.com/pages/Excel-VBA-Codes-Macros/151803898222297>
Join Us on Facebook <http://www.facebook.com/groups/163491717053198/>
P Before printing, think about the environment.
--
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
https://www.facebook.com/discussexcel
FORUM RULES
1) Use concise, accurate thread titles. Poor thread titles, like Please Help,
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.
NOTE : Don't ever post confidential data in a workbook. Forum owners and
members are not responsible for any loss.
---
You received this message because you are subscribed to the Google Groups "MS
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/excel-macros?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.