exce+training - problems copying between workshe
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and Help » exce+training - Problems copying between worksheets

exce+training - Problems copying between worksheets

The UK's most regular instructor-led training courses.
Training information: exce+training · Excel courses · VBA training in London

resolvedResolved · Low Priority · Version Standard

Problems copying between worksheets

James has attended:
Excel VBA course

by - delegate James [5 posts] (2007 Nov 20 Tue, 14:52) replyReply

Hi, The code below was generated by excel while recording a macro. It also seems to match code provided on the VBA course.

1 Range("A1").Select
2 Range("E5").Copy
3 Sheets("HPD List").Select
4 Range("B3").Select
5 ActiveSheet.Paste

When it runs though it gives an error on line 4:

Run-time error '1004':

Application-defined or Object-defined error

I think it may be something to do with a sheet being selected or acttive but have tried different combinations of selecting or activating the sheet HPD list and cell B3 and nothing works.

Any ideas please.

Excel Advanced 1 day course
Version Date Location Places
available
Book Next place rate:
Card Invoice
2003 2008 Aug 29 Fri Southwark 3 book now £224 £235
2003 2008 Sep 3 Wed Bloomsbury 5 book now £219 £235
2003 2008 Sep 5 Fri Bayswater 4 book now £195 £205
2002/XP 2008 Sep 10 Wed Tooting 0 FULL    
2003 2008 Sep 10 Wed Bloomsbury 6 book now £214 £230
2003 2008 Sep 12 Fri Southwark 7 book now £203 £230
Full Schedule: See all 127 Excel Advanced course dates.
Bookings currently available until 24th November 2009.

RE: Problems copying between worksheets

by - delegate James [5 posts] (2007 Nov 20 Tue, 15:28) replyReply

Ok, I've moved the code in to a module and it seems to work properly now.

Given my last 2 questions, is there a general rule about what must be coded within a module as opposed to being able to be coded under forms or sheets?

Thanks

RE: Problems copying between worksheets

by - trainer Carlos gold contributer[391 posts] (2008 Jan 16 Wed, 10:56) replyReply

Hi James

Sorry for the delay in answering this question.

Code entered under sheets or forms only become active when the sheet/form becomes active.

So as a rule, specially if the code is generic or needs to be used by more than one object it should always be entered in a module.

Code specific to a sheet/form, usually takes the form of event procedures eg controlling what the sheet/form does on Open, Close and all other events and also controlling any buttons and other objects embedded in it.

Regards

Carlos


Related articles

· Do You Really Need Excel VBA Training?
· What's Better Than the Help Function in Excel? Microsoft Training
· How to Create Better Excel Spreadsheets: Part One
· Microsoft Excel Training Course
· How Excel Training Can Improve Your Company's Sales Process

Excel tip:

DATEDIF function

The DATEDIF function is a worksheet function that computes the difference between two dates. This function is documented only in the help files for Excel 2000. It isn't documented in Excel 2002.
the formula function is:
=DATEDIF(Your age,Today(),"Y")
Y stands for year

View all Excel hints and tips

Institute of IT Training - Accredited Training Provider Institute of IT Training - Accredited Training Provider Prodigy Platinum Learning Partner Microsoft Office Specialist Authorised Testing Centre

Microsoft Registered Partner
microsoft office
ms office project server

Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information
AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz