macro help

R

Roy Gudgeon

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.
 
G

Gary Brown

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
'/===================
 
R

Roy Gudgeon

Thanks Gary

Modified the code a little and runs no problem.

i'm learning slowly !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top