Hi All,
I have a macro to export worksheets from the workbook to the specified path( The location path is to be set in the macros).
Problem - when I moved the macro enabled workbook to another location, i usally want to change the location path in the vba editor manually. Is there a function to export the sheets to the path where the current workbook is placed?
My macro looks like
'Creates an individual workbook for each worksheet in the active workbook.
Dim wbDest As Workbook
Dim wbSource As Workbook
Dim sht As Object 'Could be chart, worksheet, Excel 4.0 macro,etc.
Dim strSavePath As String
Application.ScreenUpdating = False 'Don't show any screen movement
strSavePath = "C:\Documents and Settings\185568\Desktop\Transact Segregation - Final\" 'Change this to suit your needs -> I dont want this to be changed manually each time whenever i move this workbook
Set wbSource = ActiveWorkbook
For Each sht In wbSource.Sheets
sht.Copy
Set wbDest = ActiveWorkbook
wbDest.SaveAs strSavePath & sht.Name
wbDest.Close 'Remove this if you don't want each book closed after saving.
Next
' deletes a sheet named strSheetName in the active workbook
Application.DisplayAlerts = False
Sheets("1").Delete
Sheets("2").Delete
Sheets("3").Delete
Sheets("4").Delete
Sheets("5").Delete
Sheets("6").Delete
Sheets("7").Delete
Sheets("8").Delete
Sheets("9").Delete
Sheets("10").Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Sheets are exported"
End Sub
"
Can anyone help on this
Hi legendkiller420
A slap on the wrist will be coming your way if you don't wrap your code in code tags. Beside that, you won't get many responses until you do so.
John
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks