Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default xlUnlockedCells ClearContents Possible ?

I have a userform to input values into a sheet.
Now after either previewing the sheet, or printing it, i have the need to
now remove the values(many) that were placed into the sheet.
Rather than tediously entering each cell by name, is there a way to
clearcontents of ALL cells that are Unlocked in the sheet ?
I tried:
with sheets("Inspections")
if xlUnlockedCells = True then
xlUnlockedCells.ClearContents
end with

But i get an error.

Is there a way i can code this ?

Corey....


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default xlUnlockedCells ClearContents Possible ?

Sub clr()
Dim c As Range

For Each c In Sheet1.UsedRange
If c.Locked = False Then
c.Clear
End If
Next
End Sub

Mike F
"Corey" wrote in message
...
I have a userform to input values into a sheet.
Now after either previewing the sheet, or printing it, i have the need to
now remove the values(many) that were placed into the sheet.
Rather than tediously entering each cell by name, is there a way to
clearcontents of ALL cells that are Unlocked in the sheet ?
I tried:
with sheets("Inspections")
if xlUnlockedCells = True then
xlUnlockedCells.ClearContents
end with

But i get an error.

Is there a way i can code this ?

Corey....



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default xlUnlockedCells ClearContents Possible ?

Thanks Mike.

Code worked great, except for some reason i have a couple of merged cells
(D9:G9) and (I9:M9) and these cells are NOT Locked, yet did not clear.
I manually coded them in to get around that.
Still saved a hell-of-a-lot-a manual coding to clear the contents.

Cheers.

Corey....
"Mike Fogleman" wrote in message
m...
Sub clr()
Dim c As Range

For Each c In Sheet1.UsedRange
If c.Locked = False Then
c.Clear
End If
Next
End Sub

Mike F
"Corey" wrote in message
...
I have a userform to input values into a sheet.
Now after either previewing the sheet, or printing it, i have the need to
now remove the values(many) that were placed into the sheet.
Rather than tediously entering each cell by name, is there a way to
clearcontents of ALL cells that are Unlocked in the sheet ?
I tried:
with sheets("Inspections")
if xlUnlockedCells = True then
xlUnlockedCells.ClearContents
end with

But i get an error.

Is there a way i can code this ?

Corey....





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default xlUnlockedCells ClearContents Possible ?

If you ever have to do it again, try changing:

c.Clear 'or c.ClearContents
to
c.value = ""



Corey wrote:

Thanks Mike.

Code worked great, except for some reason i have a couple of merged cells
(D9:G9) and (I9:M9) and these cells are NOT Locked, yet did not clear.
I manually coded them in to get around that.
Still saved a hell-of-a-lot-a manual coding to clear the contents.

Cheers.

Corey....
"Mike Fogleman" wrote in message
m...
Sub clr()
Dim c As Range

For Each c In Sheet1.UsedRange
If c.Locked = False Then
c.Clear
End If
Next
End Sub

Mike F
"Corey" wrote in message
...
I have a userform to input values into a sheet.
Now after either previewing the sheet, or printing it, i have the need to
now remove the values(many) that were placed into the sheet.
Rather than tediously entering each cell by name, is there a way to
clearcontents of ALL cells that are Unlocked in the sheet ?
I tried:
with sheets("Inspections")
if xlUnlockedCells = True then
xlUnlockedCells.ClearContents
end with

But i get an error.

Is there a way i can code this ?

Corey....




--

Dave Peterson
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
EnableSelection = xlUnlockedCells Stuart[_5_] Excel Programming 1 January 28th 05 12:39 AM
Clearcontents Caroline Vincent Excel Programming 2 September 9th 04 11:03 AM
.EnableSelection = xlUnlockedCells Stuart[_5_] Excel Programming 3 May 11th 04 03:55 PM
Clearcontents K Dales Excel Programming 0 February 27th 04 01:52 PM
Clearcontents Dick Kusleika[_3_] Excel Programming 0 February 17th 04 05:42 PM


All times are GMT +1. The time now is 11:21 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"