Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

clear data from selected cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve - 23 Jan 2006 16:03 GMT
Hello, I have a excel tempate for compiling data. How do I add a Control
button to clear data in unprotected cells only? Can you help? Steve
Tom Ogilvy - 23 Jan 2006 16:29 GMT
I assume you are looking of code and not how to add a button to a sheet

for each cell in Activesheet.UsedRange
 if cell.Locked = False then
   cell.ClearContents
 end if
Next

Signature

Regards,
Tom Ogilvy

> Hello, I have a excel tempate for compiling data. How do I add a Control
> button to clear data in unprotected cells only? Can you help? Steve
Steve - 23 Jan 2006 17:55 GMT
Hi Tom,
Yes, I already have a macro and button. I added protected cells to range, I
can't seem to edit the macro without errors. Current macros:
Sub clear()
'
' clear Macro
' Macro recorded 1/15/2006 by steve smith
'

'
   Range("B2:G10").Select
   Range("B2").Activate
   Selection.ClearContents
End Sub

I am fairly new to VB. Thank You, Steve

> I assume you are looking of code and not how to add a button to a sheet
>
[quoted text clipped - 6 lines]
> > Hello, I have a excel tempate for compiling data. How do I add a Control
> > button to clear data in unprotected cells only? Can you help? Steve
Tom Ogilvy - 23 Jan 2006 18:11 GMT
Sub clear()
'
' clear Macro
' Macro recorded 1/15/2006 by steve smith
'

'
   Dim cell as Range
   Range("B2:G10").Select
   Range("B2").Activate
   for each cell in selection
         if cell.locked = false then
             cell.ClearContents
         end if
   Next
End Sub

should work I would think.

Signature

Regards,
Tom Ogilvy

> Hi Tom,
> Yes, I already have a macro and button. I added protected cells to range, I
[quoted text clipped - 23 lines]
> > > Hello, I have a excel tempate for compiling data. How do I add a Control
> > > button to clear data in unprotected cells only? Can you help? Steve
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.