Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
macro help
I have 2 workbooks (Wb1 & WB2)
weekly I need to delete the database held in WB1, copy the database in WB2 and then paste into WB1. The database in WB2 is a hidden worksheet. Its a fairly simple operation to copy and paste manually. However I want to run a macro to carry out this procedure. I can record the macro however no matter which way I try it will not paste the information, instead it pastes the data from the first (and only unhidden worksheet ) in WB2. If I do it manually there is no problem so why a problem following exactly the same procedures in a macro ? Is the hiding operation causing a problem ? Any help much appreaciated. -- thanks Roy |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
macro help
Something like this should do it...
'/=================== Dim Wb2bCopies As Workbook Dim Wks_Hidden As Worksheet Set Wb2bCopies = Workbooks("WB2.xls") Set Wks_Hidden = Wb2bCopies.Worksheets("MyHiddenWorksheet") Wks_Hidden.Range("A1:N20").Copy ActiveSheet.Paste Set Wks_Hidden = Nothing Set Wb2 = Nothing '/=================== -- Hope this helps. If it does, please click the Yes button. Thanks in advance for your feedback. Gary Brown "Roy Gudgeon" wrote: I have 2 workbooks (Wb1 & WB2) weekly I need to delete the database held in WB1, copy the database in WB2 and then paste into WB1. The database in WB2 is a hidden worksheet. Its a fairly simple operation to copy and paste manually. However I want to run a macro to carry out this procedure. I can record the macro however no matter which way I try it will not paste the information, instead it pastes the data from the first (and only unhidden worksheet ) in WB2. If I do it manually there is no problem so why a problem following exactly the same procedures in a macro ? Is the hiding operation causing a problem ? Any help much appreaciated. -- thanks Roy |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
macro help
Thanks Gary
Modified the code a little and runs no problem. i'm learning slowly ! -- thanks Roy "Gary Brown" wrote: Something like this should do it... '/=================== Dim Wb2bCopies As Workbook Dim Wks_Hidden As Worksheet Set Wb2bCopies = Workbooks("WB2.xls") Set Wks_Hidden = Wb2bCopies.Worksheets("MyHiddenWorksheet") Wks_Hidden.Range("A1:N20").Copy ActiveSheet.Paste Set Wks_Hidden = Nothing Set Wb2 = Nothing '/=================== -- Hope this helps. If it does, please click the Yes button. Thanks in advance for your feedback. Gary Brown "Roy Gudgeon" wrote: I have 2 workbooks (Wb1 & WB2) weekly I need to delete the database held in WB1, copy the database in WB2 and then paste into WB1. The database in WB2 is a hidden worksheet. Its a fairly simple operation to copy and paste manually. However I want to run a macro to carry out this procedure. I can record the macro however no matter which way I try it will not paste the information, instead it pastes the data from the first (and only unhidden worksheet ) in WB2. If I do it manually there is no problem so why a problem following exactly the same procedures in a macro ? Is the hiding operation causing a problem ? Any help much appreaciated. -- thanks Roy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
need help to update macro to office 2007 macro enabled workbook | Excel Discussion (Misc queries) | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) |