Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple macro (ClearContent) freezes Excel


Hi,

I have this very simple macro:

Sheets("adjustment").Select
Range("B9:J25").Select
Application.CutCopyMode = False
Selection.ClearContents

Before I run this macro the following things are happening:
- datas are pasted into a different sheet
- these datas are copied into B9:J25

When the destination area contains data then this macro freezes Excel.
If there are no data then it runs "smoothly" :) (It also runs when I
put data manually into those cells)
What should I do to make this macro work?

Thanks,

Laszlo


--
bokodilaszlo
------------------------------------------------------------------------
bokodilaszlo's Profile: http://www.excelforum.com/member.php...o&userid=32250
View this thread: http://www.excelforum.com/showthread...hreadid=520012

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Simple macro (ClearContent) freezes Excel

Is your code in a Worksheet module, eg activated by a Worksheet ActiveX
control. If so and you are using Excel97 change the TakeFocusOnClick
property of the CommandButton to False. In all versions, if
Sheets("adjustment") is not the sheet containing the commandbutton this line
will fail

Range("B9:J25").Select

unless you change it to
Sheets("adjustment").Range("B9:J25").Select

But if your macro is in a normal module not sure what the problem is, try

Sheets("Sheet2").Range("B9:J25").ClearContents

Regards,
Peter T

"bokodilaszlo"
wrote in message
news:bokodilaszlo.24ce00_1141806602.2868@excelforu m-nospam.com...

Hi,

I have this very simple macro:

Sheets("adjustment").Select
Range("B9:J25").Select
Application.CutCopyMode = False
Selection.ClearContents

Before I run this macro the following things are happening:
- datas are pasted into a different sheet
- these datas are copied into B9:J25

When the destination area contains data then this macro freezes Excel.
If there are no data then it runs "smoothly" :) (It also runs when I
put data manually into those cells)
What should I do to make this macro work?

Thanks,

Laszlo


--
bokodilaszlo
------------------------------------------------------------------------
bokodilaszlo's Profile:

http://www.excelforum.com/member.php...o&userid=32250
View this thread: http://www.excelforum.com/showthread...hreadid=520012



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple macro (ClearContent) freezes Excel


Hi Peter,

Thanks for your help, I tried your suggestions but they didn't work.
I figured out that my macro is working until this line:

Selection.ClearContents

So I think the problem is in there somewhere. The funny thing is that I
wrote the same macro for different cells in different sheets and it
works there....


--
bokodilaszlo
------------------------------------------------------------------------
bokodilaszlo's Profile: http://www.excelforum.com/member.php...o&userid=32250
View this thread: http://www.excelforum.com/showthread...hreadid=520012

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple macro (ClearContent) freezes Excel


I did some searching and I found that ClearContents doesn't play
nicely with merged cells. And I had merged cells in that area
(B9:J25)!
So I modified that sheet to contain only single cells. And now the
macro works fine :)


--
bokodilaszlo
------------------------------------------------------------------------
bokodilaszlo's Profile: http://www.excelforum.com/member.php...o&userid=32250
View this thread: http://www.excelforum.com/showthread...hreadid=520012

Reply
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
Excel Macro runs fine, but freezes if I try to do ANYTHING else whileit's running Rruffpaw Setting up and Configuration of Excel 0 August 3rd 11 08:31 PM
Macro freezes spreadsheet davemel Excel Discussion (Misc queries) 0 August 1st 06 08:26 AM
Macro freezes up Excel Jon Delano Excel Programming 4 August 11th 05 07:54 PM
Find and clearcontent Dave Peterson[_3_] Excel Programming 0 June 26th 04 04:20 AM
Macro freezes Excel Yohan[_2_] Excel Programming 4 February 17th 04 02:12 PM


All times are GMT +1. The time now is 07:49 AM.

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"