can you make my code smarter?

Eurekaonide

Active Member
Joined
Feb 1, 2010
Messages
433
Hi All

I ahve some code that is actually working fine, however I wonder if you can make it smarter for me please?

Basically it picks up data and pastes it into a new workbook to create a moment in time report.

In order for it to then go back to the original workbook and tidy everything back up and essentially reset it for the next time, my code uses the below example to go back to the original workbook via its name. Whilst this does work it also means that if the users changes the name the code needs to be updated. Is there any way therefore where I can get it to go back to the original workbook (which could be in a number of directories) without needing to specify its actual name?

Any advice would be much appreciated.

HTML:
'=====================================================
'Push to another Workbook
'=====================================================
Sheets("Summary Report").Select
Columns("A:T").Select
Selection.Copy
Workbooks.Add
Cells.Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
        , AllowFormattingCells:=True, AllowFormattingColumns:=True, _
        AllowFormattingRows:=True
ActiveWorkbook.UpdateLinks = xlUpdateLinksNever
'need to refer back to the original Workbook - NEED TO CHANGE THE NAME FOR EACH WORKBOOK !!!
'--------------------------------------------------------------------------------------------
Windows("Project Workbook Template V6.5.xls").Activate
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
having another thought on this, do you think it would be appropriate to have a text type of dialogue box that the administrator / user could type the new name of the workbook and this then changes the code to update the name??

What I'm trying to do is make non VBA users life easier when changing or administering this workbook without having to worry about going into the depths of the code.
 
Upvote 0
why not just do a SAVE AS with format(now(),"yyy_mmm_dd_hh_nn_SS") stuck on the end of the current workbook name
if you haven't saved the original then it won't need clearing up?
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,266
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top