LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Works as Macro but not in code

This is really perplexing me! I have a very, very simple action to perform
(select a worksheet, select column A, clear contents, return to different
sheet).

If I record a Macro it works fine. If I take the code from the macro and
use it as part of a longer sub, it falls over.

Code:

Sub ClearA()

Sheets("Statistics").Select
Columns("A:A").Select ' // falls over here
Selection.ClearContents
Sheets("NameList").Select

End Sub

It falls over with the error message :

Runtime Error '1004'
Select method of Range class failed


I must be missing something obvious but I'm darned if I can see why it works
as a Macro and not in a sub. Can anyone help please?

This shouldn't have held me up for the last two hours but it has!!

Thanks in advance
Sue



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
code works - need to save Ted Roche Excel Discussion (Misc queries) 1 January 7th 09 06:08 PM
Code works for any WBK except the PMW Mark Tangard[_3_] Excel Programming 3 July 17th 05 11:54 AM
Half of the code works? hotherps[_140_] Excel Programming 1 September 2nd 04 11:55 PM
Why won't this code works ksnapp[_37_] Excel Programming 6 April 1st 04 01:44 PM
VBA Code Works in 97, Not in 2002 William[_2_] Excel Programming 11 August 12th 03 02:05 AM


All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"