Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default "ClearContents" command halts code

I have a routine that highlights a range and removes any entries in
that range. For some reason the ClearContents command halts processing
AFTER it has performed the removal of entries. If I comment that line
out the routine runs as expected.

The code is
Sub PoP5()
If Sheets("Intro").Range("h16").Value = False Then
Sheets("Labor").Select
Worksheets("Labor").Unprotect Password:="xxx1"
Range("ba4:ba53").ClearContents
Columns("AU:BB").Select
Selection.EntireColumn.Hidden = True
{snip}

With the commented out, the columns hide and processing continues;
with the ClearContents active the entries are removed but processing
stops. I tried breaking that line into two, comme ca:
Range("ba4:ba53").Select
Selection.ClearContents
....to no avail, the same thing happens.

Anyone have thoughts for the cause, or a workaround?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default "ClearContents" command halts code

This works fine for me if "Intro" sheet H16 = False

Clears the contents then hides the columns and pops up the message box with
"done"

You're saying that the columns do not get hidden on "Labor" sheet?

Sub PoP5()
If Sheets("Intro").Range("h16").Value = False Then
Sheets("Labor").Select
Worksheets("Labor").Unprotect Password:="xxx1"
Range("ba4:ba53").ClearContents
Columns("AU:BB").Select
Selection.EntireColumn.Hidden = True
End If
MsgBox "done"
End Sub

Note: you don't need the select to hide the columns.

Columns("AU:BB").EntireColumn.Hidden = True


Gord Dibben MS Excel MVP

On Wed, 9 Jan 2008 14:04:16 -0800 (PST), Dave O wrote:

I have a routine that highlights a range and removes any entries in
that range. For some reason the ClearContents command halts processing
AFTER it has performed the removal of entries. If I comment that line
out the routine runs as expected.

The code is
Sub PoP5()
If Sheets("Intro").Range("h16").Value = False Then
Sheets("Labor").Select
Worksheets("Labor").Unprotect Password:="xxx1"
Range("ba4:ba53").ClearContents
Columns("AU:BB").Select
Selection.EntireColumn.Hidden = True
{snip}

With the commented out, the columns hide and processing continues;
with the ClearContents active the entries are removed but processing
stops. I tried breaking that line into two, comme ca:
Range("ba4:ba53").Select
Selection.ClearContents
...to no avail, the same thing happens.

Anyone have thoughts for the cause, or a workaround?

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default "ClearContents" command halts code

Do you have any event macros that could be messing up?

Sub PoP5()
If Sheets("Intro").Range("h16").Value = False Then
with workSheets("Labor")
.Unprotect Password:="xxx1"
application.enableevents = false
.Range("ba4:ba53").ClearContents
application.enableevents = true
.Columns("AU:BB").EntireColumn.Hidden = True
end with
end if

I also deleted the .select's.

Dave O wrote:

I have a routine that highlights a range and removes any entries in
that range. For some reason the ClearContents command halts processing
AFTER it has performed the removal of entries. If I comment that line
out the routine runs as expected.

The code is
Sub PoP5()
If Sheets("Intro").Range("h16").Value = False Then
Sheets("Labor").Select
Worksheets("Labor").Unprotect Password:="xxx1"
Range("ba4:ba53").ClearContents
Columns("AU:BB").Select
Selection.EntireColumn.Hidden = True
{snip}

With the commented out, the columns hide and processing continues;
with the ClearContents active the entries are removed but processing
stops. I tried breaking that line into two, comme ca:
Range("ba4:ba53").Select
Selection.ClearContents
...to no avail, the same thing happens.

Anyone have thoughts for the cause, or a workaround?

Thanks


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default "ClearContents" command halts code

Thanks, Gord and Dave. It was, in fact, an event macro: I'd altered it
to solve one problem, and wound up creating another.
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
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Is there an equivalent of Lotus 123's "Paste visible" command? AJ Excel Discussion (Misc queries) 6 March 16th 06 09:21 AM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM


All times are GMT +1. The time now is 12:57 PM.

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

About Us

"It's about Microsoft Excel"